Move all X specific code into the x11/ directory. Aside from shuffling
authorOwen Taylor <otaylor@redhat.com>
Mon, 8 Nov 1999 20:14:59 +0000 (20:14 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 8 Nov 1999 20:14:59 +0000 (20:14 +0000)
Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>

Move all X specific code into the x11/ directory.
Aside from shuffling things around, did the following:

       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
 gdk_arg_context_* - a simple argument parsing system
 in the style of popt.

       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
 gdk/x11/gdkprivate-x11.h:
 Remove X specific stuff from GdkDrawable and GdkWindowPrivate -
 add ->klass and ->klass_data fields. The klass_data
 field points to an auxilliary structure that is
 windowing system dependent.

       * gdk/gdkfont.c: Make most of the measurement functions
 simply wrappers around gdk_text_extents().

       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a
 _gdk_font_strlen() function that hides the weird
 behavior in gtk+-1.[02] where a string is interpreted
 differently for 8-bit and 16-bit fonts.

       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
 to store common code for synthesizing double/triple
 press events.

       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
 Make all the function that modify an existing GC
 simply wrappers around gdk_gc_set_values().

       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
 for throwing out later.

       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
 GdkImagePrivate and GdkColormapPrivate to have a
 windowing system dependent part (GdkFontPrivateX etc.)
 that "derives" from the system-independent part.

       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
 Got rid of the included-source-files for XInput in
 favor of automake conditionals. (Which didn't exist
 when XInput support was originally added.)

       * gdk/gdkrgb.c: Remove the visual id from the debugging
 statements since that is X11 specific; print out
 type/depth info instead.

77 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
configure.in
gdk/Makefile.am
gdk/MwmUtil.h [deleted file]
gdk/TODO
gdk/gdk.c
gdk/gdk.h
gdk/gdkcc.c [deleted file]
gdk/gdkcolor.c
gdk/gdkcompat.h
gdk/gdkcursor.c [deleted file]
gdk/gdkdnd.c [deleted file]
gdk/gdkdraw.c
gdk/gdkdrawable.h
gdk/gdkevents.c
gdk/gdkfont.c
gdk/gdkgc.c
gdk/gdkgc.h
gdk/gdkglobals.c
gdk/gdkim.c [deleted file]
gdk/gdkimage.c
gdk/gdkimage.h
gdk/gdkinput.c [deleted file]
gdk/gdkinputcommon.h [deleted file]
gdk/gdkinputgxi.h [deleted file]
gdk/gdkinputnone.h [deleted file]
gdk/gdkinputprivate.h [deleted file]
gdk/gdkinputxfree.h [deleted file]
gdk/gdkpixmap.c [deleted file]
gdk/gdkprivate.h
gdk/gdkproperty.c [deleted file]
gdk/gdkregion.c [deleted file]
gdk/gdkrgb.c
gdk/gdkselection.c [deleted file]
gdk/gdkvisual.c [deleted file]
gdk/gdkwindow.c
gdk/gdkwindow.h
gdk/gdkx.h [deleted file]
gdk/gdkxid.c [deleted file]
gdk/win32/gdkevents-win32.c
gdk/win32/gdkevents.c
gdk/x11/Makefile.am
gdk/x11/gdkcc-x11.c
gdk/x11/gdkcolor-x11.c
gdk/x11/gdkcursor-x11.c
gdk/x11/gdkdnd-x11.c
gdk/x11/gdkdrawable-x11.c [new file with mode: 0644]
gdk/x11/gdkevents-x11.c
gdk/x11/gdkfont-x11.c
gdk/x11/gdkgc-x11.c [new file with mode: 0644]
gdk/x11/gdkglobals-x11.c
gdk/x11/gdkimage-x11.c
gdk/x11/gdkinput-gxi.c
gdk/x11/gdkinput-none.c
gdk/x11/gdkinput-x11.c
gdk/x11/gdkinput-xfree.c
gdk/x11/gdkinput.c
gdk/x11/gdkinputprivate.h
gdk/x11/gdkmain-x11.c
gdk/x11/gdkpixmap-x11.c
gdk/x11/gdkprivate-x11.h [new file with mode: 0644]
gdk/x11/gdkproperty-x11.c
gdk/x11/gdkregion-x11.c
gdk/x11/gdkvisual-x11.c
gdk/x11/gdkwindow-x11.c
gdk/x11/gdkx.h
gdk/x11/gdkxid.c
gtk/Makefile.am
gtk/gtkwidget.h
gtk/simple.c
tests/simple.c

index d7b557e905a641d5156bd26662dd37df7e09dc5c..e1aa8e4418b02bc732b6d416530a7e1421e37e0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,65 @@
+Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>
+
+       Move all X specific code into the x11/ directory.
+       Aside from shuffling things around, did the following:
+
+       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
+        gdk_arg_context_* - a simple argument parsing system
+        in the style of popt.
+
+       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
+        gdk/x11/gdkprivate-x11.h:
+        Remove X specific stuff from GdkDrawable and GdkWindowPrivate - 
+        add ->klass and ->klass_data fields. The klass_data
+        field points to an auxilliary structure that is
+        windowing system dependent.
+
+       * gdk/gdkfont.c: Make most of the measurement functions
+        simply wrappers around gdk_text_extents().
+
+       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a 
+        _gdk_font_strlen() function that hides the weird
+        behavior in gtk+-1.[02] where a string is interpreted
+        differently for 8-bit and 16-bit fonts.
+
+       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
+        to store common code for synthesizing double/triple
+        press events.
+       
+       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
+        Make all the function that modify an existing GC
+        simply wrappers around gdk_gc_set_values().
+        
+       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
+        for throwing out later.
+
+       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
+        GdkImagePrivate and GdkColormapPrivate to have a
+        windowing system dependent part (GdkFontPrivateX etc.)
+        that "derives" from the system-independent part.
+
+       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
+        Got rid of the included-source-files for XInput in
+        favor of automake conditionals. (Which didn't exist
+        when XInput support was originally added.)
+
+       * gdk/gdkrgb.c: Remove the visual id from the debugging
+        statements since that is X11 specific; print out
+        type/depth info instead.
+        
+
+Wed Nov  3 18:14:49 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
+       loading duplicates of hashed fonts.
+
+       * gdk/gdk.c (gdk_keysym_convert_case): rename
+       gdk_XConvertCase to gdk_keysym_convert_case, allow
+       results to be NULL in the GTK+ style.
+
+       * gdk/gdkcompat.h: Started compatibility header
+       for renames.
+
 1999-11-07  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkprivate.h: New font private structures, related to
index d7b557e905a641d5156bd26662dd37df7e09dc5c..e1aa8e4418b02bc732b6d416530a7e1421e37e0f 100644 (file)
@@ -1,3 +1,65 @@
+Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>
+
+       Move all X specific code into the x11/ directory.
+       Aside from shuffling things around, did the following:
+
+       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
+        gdk_arg_context_* - a simple argument parsing system
+        in the style of popt.
+
+       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
+        gdk/x11/gdkprivate-x11.h:
+        Remove X specific stuff from GdkDrawable and GdkWindowPrivate - 
+        add ->klass and ->klass_data fields. The klass_data
+        field points to an auxilliary structure that is
+        windowing system dependent.
+
+       * gdk/gdkfont.c: Make most of the measurement functions
+        simply wrappers around gdk_text_extents().
+
+       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a 
+        _gdk_font_strlen() function that hides the weird
+        behavior in gtk+-1.[02] where a string is interpreted
+        differently for 8-bit and 16-bit fonts.
+
+       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
+        to store common code for synthesizing double/triple
+        press events.
+       
+       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
+        Make all the function that modify an existing GC
+        simply wrappers around gdk_gc_set_values().
+        
+       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
+        for throwing out later.
+
+       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
+        GdkImagePrivate and GdkColormapPrivate to have a
+        windowing system dependent part (GdkFontPrivateX etc.)
+        that "derives" from the system-independent part.
+
+       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
+        Got rid of the included-source-files for XInput in
+        favor of automake conditionals. (Which didn't exist
+        when XInput support was originally added.)
+
+       * gdk/gdkrgb.c: Remove the visual id from the debugging
+        statements since that is X11 specific; print out
+        type/depth info instead.
+        
+
+Wed Nov  3 18:14:49 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
+       loading duplicates of hashed fonts.
+
+       * gdk/gdk.c (gdk_keysym_convert_case): rename
+       gdk_XConvertCase to gdk_keysym_convert_case, allow
+       results to be NULL in the GTK+ style.
+
+       * gdk/gdkcompat.h: Started compatibility header
+       for renames.
+
 1999-11-07  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkprivate.h: New font private structures, related to
index d7b557e905a641d5156bd26662dd37df7e09dc5c..e1aa8e4418b02bc732b6d416530a7e1421e37e0f 100644 (file)
@@ -1,3 +1,65 @@
+Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>
+
+       Move all X specific code into the x11/ directory.
+       Aside from shuffling things around, did the following:
+
+       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
+        gdk_arg_context_* - a simple argument parsing system
+        in the style of popt.
+
+       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
+        gdk/x11/gdkprivate-x11.h:
+        Remove X specific stuff from GdkDrawable and GdkWindowPrivate - 
+        add ->klass and ->klass_data fields. The klass_data
+        field points to an auxilliary structure that is
+        windowing system dependent.
+
+       * gdk/gdkfont.c: Make most of the measurement functions
+        simply wrappers around gdk_text_extents().
+
+       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a 
+        _gdk_font_strlen() function that hides the weird
+        behavior in gtk+-1.[02] where a string is interpreted
+        differently for 8-bit and 16-bit fonts.
+
+       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
+        to store common code for synthesizing double/triple
+        press events.
+       
+       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
+        Make all the function that modify an existing GC
+        simply wrappers around gdk_gc_set_values().
+        
+       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
+        for throwing out later.
+
+       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
+        GdkImagePrivate and GdkColormapPrivate to have a
+        windowing system dependent part (GdkFontPrivateX etc.)
+        that "derives" from the system-independent part.
+
+       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
+        Got rid of the included-source-files for XInput in
+        favor of automake conditionals. (Which didn't exist
+        when XInput support was originally added.)
+
+       * gdk/gdkrgb.c: Remove the visual id from the debugging
+        statements since that is X11 specific; print out
+        type/depth info instead.
+        
+
+Wed Nov  3 18:14:49 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
+       loading duplicates of hashed fonts.
+
+       * gdk/gdk.c (gdk_keysym_convert_case): rename
+       gdk_XConvertCase to gdk_keysym_convert_case, allow
+       results to be NULL in the GTK+ style.
+
+       * gdk/gdkcompat.h: Started compatibility header
+       for renames.
+
 1999-11-07  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkprivate.h: New font private structures, related to
index d7b557e905a641d5156bd26662dd37df7e09dc5c..e1aa8e4418b02bc732b6d416530a7e1421e37e0f 100644 (file)
@@ -1,3 +1,65 @@
+Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>
+
+       Move all X specific code into the x11/ directory.
+       Aside from shuffling things around, did the following:
+
+       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
+        gdk_arg_context_* - a simple argument parsing system
+        in the style of popt.
+
+       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
+        gdk/x11/gdkprivate-x11.h:
+        Remove X specific stuff from GdkDrawable and GdkWindowPrivate - 
+        add ->klass and ->klass_data fields. The klass_data
+        field points to an auxilliary structure that is
+        windowing system dependent.
+
+       * gdk/gdkfont.c: Make most of the measurement functions
+        simply wrappers around gdk_text_extents().
+
+       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a 
+        _gdk_font_strlen() function that hides the weird
+        behavior in gtk+-1.[02] where a string is interpreted
+        differently for 8-bit and 16-bit fonts.
+
+       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
+        to store common code for synthesizing double/triple
+        press events.
+       
+       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
+        Make all the function that modify an existing GC
+        simply wrappers around gdk_gc_set_values().
+        
+       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
+        for throwing out later.
+
+       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
+        GdkImagePrivate and GdkColormapPrivate to have a
+        windowing system dependent part (GdkFontPrivateX etc.)
+        that "derives" from the system-independent part.
+
+       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
+        Got rid of the included-source-files for XInput in
+        favor of automake conditionals. (Which didn't exist
+        when XInput support was originally added.)
+
+       * gdk/gdkrgb.c: Remove the visual id from the debugging
+        statements since that is X11 specific; print out
+        type/depth info instead.
+        
+
+Wed Nov  3 18:14:49 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
+       loading duplicates of hashed fonts.
+
+       * gdk/gdk.c (gdk_keysym_convert_case): rename
+       gdk_XConvertCase to gdk_keysym_convert_case, allow
+       results to be NULL in the GTK+ style.
+
+       * gdk/gdkcompat.h: Started compatibility header
+       for renames.
+
 1999-11-07  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkprivate.h: New font private structures, related to
index d7b557e905a641d5156bd26662dd37df7e09dc5c..e1aa8e4418b02bc732b6d416530a7e1421e37e0f 100644 (file)
@@ -1,3 +1,65 @@
+Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>
+
+       Move all X specific code into the x11/ directory.
+       Aside from shuffling things around, did the following:
+
+       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
+        gdk_arg_context_* - a simple argument parsing system
+        in the style of popt.
+
+       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
+        gdk/x11/gdkprivate-x11.h:
+        Remove X specific stuff from GdkDrawable and GdkWindowPrivate - 
+        add ->klass and ->klass_data fields. The klass_data
+        field points to an auxilliary structure that is
+        windowing system dependent.
+
+       * gdk/gdkfont.c: Make most of the measurement functions
+        simply wrappers around gdk_text_extents().
+
+       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a 
+        _gdk_font_strlen() function that hides the weird
+        behavior in gtk+-1.[02] where a string is interpreted
+        differently for 8-bit and 16-bit fonts.
+
+       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
+        to store common code for synthesizing double/triple
+        press events.
+       
+       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
+        Make all the function that modify an existing GC
+        simply wrappers around gdk_gc_set_values().
+        
+       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
+        for throwing out later.
+
+       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
+        GdkImagePrivate and GdkColormapPrivate to have a
+        windowing system dependent part (GdkFontPrivateX etc.)
+        that "derives" from the system-independent part.
+
+       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
+        Got rid of the included-source-files for XInput in
+        favor of automake conditionals. (Which didn't exist
+        when XInput support was originally added.)
+
+       * gdk/gdkrgb.c: Remove the visual id from the debugging
+        statements since that is X11 specific; print out
+        type/depth info instead.
+        
+
+Wed Nov  3 18:14:49 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
+       loading duplicates of hashed fonts.
+
+       * gdk/gdk.c (gdk_keysym_convert_case): rename
+       gdk_XConvertCase to gdk_keysym_convert_case, allow
+       results to be NULL in the GTK+ style.
+
+       * gdk/gdkcompat.h: Started compatibility header
+       for renames.
+
 1999-11-07  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkprivate.h: New font private structures, related to
index d7b557e905a641d5156bd26662dd37df7e09dc5c..e1aa8e4418b02bc732b6d416530a7e1421e37e0f 100644 (file)
@@ -1,3 +1,65 @@
+Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>
+
+       Move all X specific code into the x11/ directory.
+       Aside from shuffling things around, did the following:
+
+       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
+        gdk_arg_context_* - a simple argument parsing system
+        in the style of popt.
+
+       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
+        gdk/x11/gdkprivate-x11.h:
+        Remove X specific stuff from GdkDrawable and GdkWindowPrivate - 
+        add ->klass and ->klass_data fields. The klass_data
+        field points to an auxilliary structure that is
+        windowing system dependent.
+
+       * gdk/gdkfont.c: Make most of the measurement functions
+        simply wrappers around gdk_text_extents().
+
+       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a 
+        _gdk_font_strlen() function that hides the weird
+        behavior in gtk+-1.[02] where a string is interpreted
+        differently for 8-bit and 16-bit fonts.
+
+       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
+        to store common code for synthesizing double/triple
+        press events.
+       
+       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
+        Make all the function that modify an existing GC
+        simply wrappers around gdk_gc_set_values().
+        
+       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
+        for throwing out later.
+
+       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
+        GdkImagePrivate and GdkColormapPrivate to have a
+        windowing system dependent part (GdkFontPrivateX etc.)
+        that "derives" from the system-independent part.
+
+       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
+        Got rid of the included-source-files for XInput in
+        favor of automake conditionals. (Which didn't exist
+        when XInput support was originally added.)
+
+       * gdk/gdkrgb.c: Remove the visual id from the debugging
+        statements since that is X11 specific; print out
+        type/depth info instead.
+        
+
+Wed Nov  3 18:14:49 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
+       loading duplicates of hashed fonts.
+
+       * gdk/gdk.c (gdk_keysym_convert_case): rename
+       gdk_XConvertCase to gdk_keysym_convert_case, allow
+       results to be NULL in the GTK+ style.
+
+       * gdk/gdkcompat.h: Started compatibility header
+       for renames.
+
 1999-11-07  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkprivate.h: New font private structures, related to
index d7b557e905a641d5156bd26662dd37df7e09dc5c..e1aa8e4418b02bc732b6d416530a7e1421e37e0f 100644 (file)
@@ -1,3 +1,65 @@
+Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>
+
+       Move all X specific code into the x11/ directory.
+       Aside from shuffling things around, did the following:
+
+       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
+        gdk_arg_context_* - a simple argument parsing system
+        in the style of popt.
+
+       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
+        gdk/x11/gdkprivate-x11.h:
+        Remove X specific stuff from GdkDrawable and GdkWindowPrivate - 
+        add ->klass and ->klass_data fields. The klass_data
+        field points to an auxilliary structure that is
+        windowing system dependent.
+
+       * gdk/gdkfont.c: Make most of the measurement functions
+        simply wrappers around gdk_text_extents().
+
+       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a 
+        _gdk_font_strlen() function that hides the weird
+        behavior in gtk+-1.[02] where a string is interpreted
+        differently for 8-bit and 16-bit fonts.
+
+       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
+        to store common code for synthesizing double/triple
+        press events.
+       
+       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
+        Make all the function that modify an existing GC
+        simply wrappers around gdk_gc_set_values().
+        
+       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
+        for throwing out later.
+
+       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
+        GdkImagePrivate and GdkColormapPrivate to have a
+        windowing system dependent part (GdkFontPrivateX etc.)
+        that "derives" from the system-independent part.
+
+       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
+        Got rid of the included-source-files for XInput in
+        favor of automake conditionals. (Which didn't exist
+        when XInput support was originally added.)
+
+       * gdk/gdkrgb.c: Remove the visual id from the debugging
+        statements since that is X11 specific; print out
+        type/depth info instead.
+        
+
+Wed Nov  3 18:14:49 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/x11/gdkfont-x11.c (gdk_font_load): Ref fonts when
+       loading duplicates of hashed fonts.
+
+       * gdk/gdk.c (gdk_keysym_convert_case): rename
+       gdk_XConvertCase to gdk_keysym_convert_case, allow
+       results to be NULL in the GTK+ style.
+
+       * gdk/gdkcompat.h: Started compatibility header
+       for renames.
+
 1999-11-07  Tor Lillqvist  <tml@iki.fi>
 
        * gdk/win32/gdkprivate.h: New font private structures, related to
index e0f93a01223e2c8410825e1379e4918581106bc1..4817b9521a8c404c4df1aa35ab4f2d94edc1f52e 100644 (file)
@@ -406,6 +406,9 @@ else
   AC_DEFINE(XINPUT_NONE)
 fi
 
+AM_CONDITIONAL(XINPUT_GXI, test x$with_xinput = xgxi)
+AM_CONDITIONAL(XINPUT_XFREE, test x$with_xinput = xxfree)
+
 CFLAGS="$saved_cflags"
 LDFLAGS="$saved_ldflags"
 
index 79311c8c156d8a06c2c0535d1f4ce9da3031166c..0cc2a72e471e820773c2e0d0f685f85f074940e3 100644 (file)
@@ -44,6 +44,7 @@ gdk_public_h_sources = @STRIP_BEGIN@ \
        gdk.h           \
        gdkcc.h         \
        gdkcolor.h      \
+       gdkcompat.h     \
        gdkcursor.h     \
        gdkcursors.h    \
        gdkdnd.h        \
@@ -65,36 +66,19 @@ gdk_public_h_sources = @STRIP_BEGIN@ \
        gdktypes.h      \
        gdkvisual.h     \
        gdkwindow.h     \
-       gdkx.h          \
 @STRIP_END@
 gdk_c_sources = @STRIP_BEGIN@ \
        gdk.c           \
-       gdkcc.c         \
        gdkcolor.c      \
-       gdkcursor.c     \
-       gdkdnd.c        \
        gdkdraw.c       \
        gdkevents.c     \
        gdkfont.c       \
        gdkgc.c         \
        gdkglobals.c    \
-       gdkim.c         \
        gdkimage.c      \
-       gdkinput.c      \
-       gdkinput.h      \
-       gdkinputnone.h  \
-       gdkinputcommon.h\
-       gdkinputgxi.h   \
-       gdkinputxfree.h \
-       gdkpixmap.c     \
-       gdkproperty.c   \
        gdkrgb.c        \
        gdkrectangle.c  \
-       gdkregion.c     \
-       gdkselection.c  \
-       gdkvisual.c     \
        gdkwindow.c     \
-       gdkxid.c        \
        MwmUtil.h       \
 @STRIP_END@
 
diff --git a/gdk/MwmUtil.h b/gdk/MwmUtil.h
deleted file mode 100644 (file)
index 53925f6..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- *
- * $Id$
- *
- * Copyright (C) 1995 Free Software Foundation, Inc.
- *
- * This file is part of the GNU LessTif Library.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- *
- * * Feb 21 1999 - George Lebl (jirka@5z.com)
- *                 Owen Taylor (otaylor@redhat.com)
- *
- *   Modified so that the MotifWmHints structure defined here
- *   is suitable for client side use on 64-bit architectures.
- *   X expects fields with a format of 32 to be longs, even
- *   when sizeof(long) == 8.
- **/
-
-#ifndef MWMUTIL_H_INCLUDED
-#define MWMUTIL_H_INCLUDED
-
-#include <X11/Xmd.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
-    unsigned long flags;
-    unsigned long functions;
-    unsigned long decorations;
-    long input_mode;
-    unsigned long status;
-} MotifWmHints, MwmHints;
-
-#define MWM_HINTS_FUNCTIONS     (1L << 0)
-#define MWM_HINTS_DECORATIONS   (1L << 1)
-#define MWM_HINTS_INPUT_MODE    (1L << 2)
-#define MWM_HINTS_STATUS        (1L << 3)
-
-#define MWM_FUNC_ALL            (1L << 0)
-#define MWM_FUNC_RESIZE         (1L << 1)
-#define MWM_FUNC_MOVE           (1L << 2)
-#define MWM_FUNC_MINIMIZE       (1L << 3)
-#define MWM_FUNC_MAXIMIZE       (1L << 4)
-#define MWM_FUNC_CLOSE          (1L << 5)
-
-#define MWM_DECOR_ALL           (1L << 0)
-#define MWM_DECOR_BORDER        (1L << 1)
-#define MWM_DECOR_RESIZEH       (1L << 2)
-#define MWM_DECOR_TITLE         (1L << 3)
-#define MWM_DECOR_MENU          (1L << 4)
-#define MWM_DECOR_MINIMIZE      (1L << 5)
-#define MWM_DECOR_MAXIMIZE      (1L << 6)
-
-#define MWM_INPUT_MODELESS 0
-#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
-#define MWM_INPUT_SYSTEM_MODAL 2
-#define MWM_INPUT_FULL_APPLICATION_MODAL 3
-#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
-
-#define MWM_TEAROFF_WINDOW     (1L<<0)
-
-/*
- * atoms
- */
-#define _XA_MOTIF_BINDINGS             "_MOTIF_BINDINGS"
-#define _XA_MOTIF_WM_HINTS             "_MOTIF_WM_HINTS"
-#define _XA_MOTIF_WM_MESSAGES          "_MOTIF_WM_MESSAGES"
-#define _XA_MOTIF_WM_OFFSET            "_MOTIF_WM_OFFSET"
-#define _XA_MOTIF_WM_MENU              "_MOTIF_WM_MENU"
-#define _XA_MOTIF_WM_INFO              "_MOTIF_WM_INFO"
-#define _XA_MWM_HINTS                  _XA_MOTIF_WM_HINTS
-#define _XA_MWM_MESSAGES               _XA_MOTIF_WM_MESSAGES
-#define _XA_MWM_MENU                   _XA_MOTIF_WM_MENU
-#define _XA_MWM_INFO                   _XA_MOTIF_WM_INFO
-
-
-/*
- * _MWM_INFO property
- */
-typedef struct {
-    long flags;
-    Window wm_window;
-} MotifWmInfo;
-
-typedef MotifWmInfo MwmInfo;
-
-#define MWM_INFO_STARTUP_STANDARD      (1L<<0)
-#define MWM_INFO_STARTUP_CUSTOM                (1L<<1)
-
-/*
- * _MWM_HINTS property
- */
-typedef struct {
-    unsigned long flags;
-    unsigned long functions;
-    unsigned long decorations;
-    long inputMode;
-    unsigned long status;
-} PropMotifWmHints;
-
-typedef PropMotifWmHints PropMwmHints;
-
-#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
-#define PROP_MWM_HINTS_ELEMENTS PROP_MOTIF_WM_HINTS_ELEMENTS
-
-/*
- * _MWM_INFO property, slight return
- */
-typedef struct {
-    unsigned long flags;
-    unsigned long wmWindow;
-} PropMotifWmInfo;
-
-typedef PropMotifWmInfo PropMwmInfo;
-
-#define PROP_MOTIF_WM_INFO_ELEMENTS 2
-#define PROP_MWM_INFO_ELEMENTS PROP_MOTIF_WM_INFO_ELEMENTS
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MWMUTIL_H_INCLUDED */
index 6f6191d6d6179ae38578a9898dd46873f5fcc2be..f16cfb9b85b70562aa188fc1c6740af1c9633329 100644 (file)
--- a/gdk/TODO
+++ b/gdk/TODO
@@ -4,6 +4,10 @@ General
 - gdk_pointer_grab() and gdk_keyboard_grab() are logically member
   functions of GdkWindow.
 
+X specific Functions that need to be moved out of the common header files
+=========================================================================
+
+
 Dir structure for ports
 =======================
 
@@ -56,6 +60,119 @@ files in the directory, and also for building any
 X-specific utilities. (Such as the gxid daemon).
 
 
+Port Status for Files
+=====================
+
+gdk
+
+ Much of the contents have been moved to x11/gtkmain.c. 
+ I've added a little argument-parsing abstraction.
+ (Currently called gdk_arg_context_*) that allows 
+ arguments from multiple places to be combined - that
+ probably needs to be either fixed up and moved into
+ GLib or replaced with some existing solution like
+ popt.
+
+gdkcc
+
+ This will be removed for GTK+-1.4. Right now, it has been moved
+ completely into the x11/ directory to avoid having to port it.
+
+gdkcolor
+
+ There are a few common utility functions, and the rest
+ is in the port-specific files.
+
+gdkcursor
+
+ No shared code - completely port-specific.
+
+gdkdnd
+
+ No shared code - completely arch-specific. It's possible that some
+ common code for handling GdkDragContext could exist, but the
+ GdkDragContextPrivate will be different on each port.
+
+gdkdrawable
+
+ Pretty much done. GdkDrawable is completely virtualized.
+
+gdkevents
+
+ There are a few common utility functions, and the rest
+ is in the port-specific files.
+
+gdkfont
+
+ Pretty much done for now - gdkfont.c contains a number of functions
+ reimplemented as utility functions, and the rest is
+ ports-specific. It will be obsoleted by pango before 1.4.
+
+gdkgc
+
+ GdkGC is virtualized to go along with GdkDrawable. There are
+ a couple of functions I punted on for now and moved into the
+ port-specific files - the clipmask functions (because gdkregion
+ is not finalized) and also gdk_gc_copy, which I'm not sure
+ I like enough to put into the vtable.
+
+gdkim
+
+ All in the port-specific directories. The abstraction here probably
+ will be changed at some point to something more convenient and
+ more Unicode-based.
+
+gdkimage
+
+ GdkImage is virtualized - all of the code except for ref/unref
+ is in the port-specific files.
+
+gdkinput
+
+ Right now all the code is port-specific. It should be possible 
+ to share the code in gdkinputnone.c, but probably not worth it; 
+ I'd like to get rid of the gdk_input_vtable in X11 code - 
+ it doesn't make sense since you can't switch the type of input
+ on the fly.
+
+gdkpixmap
+
+ All moved into the port-specific file for now. The xpm loader
+ should be changed to render with GdkRGB, and thus be 
+ windowing-system independent, but that requires
+ first making GdkRGB able to render onto any arbitrary visual.
+
+gdkproperty
+
+ All port-specific. Possibly should be X-specific with a higher-level
+ clipboard API on top of it.
+
+gdkregion
+
+ Right now punted to being port-specific, but that probably needs
+ to change with the virtualized drawables and GC's.
+
+gdkrgb
+
+ With a few changes to debugging code, it was already port-independent.
+
+gdkselection
+
+ Completely port specific. (In fact, really doesn't make sense
+ on anything other than X; a higher-level clipboard facility
+ should be provided somewhere, though.)
+
+gdkvisual
+ Completely port-specific. (The concepts are rather X-specific)
+
+gdkwindow
+
+ The window-private data is split between windowing-system independent
+ parts and windowing system dependent parts. There are a few
+ functions in gdk/gdkwindow.c and the rest is moved off
+ into x11/gdkwindow-x11.c
+
 Virtualization
 ==============
 
index 4e8b83f803cd5073a86d68a0b0465aad2ab31bab..4b7e37d3cdf35d732f7eb455b0f79c45479aac3e 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
 
 #include "config.h"
 
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
-#include <limits.h>
-#include <errno.h>
-
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif /* HAVE_SYS_SELECT_H_ */
-
-#define XLIB_ILLEGAL_ACCESS
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <X11/Xos.h>
-#include <X11/Xutil.h>
-#include <X11/Xmu/WinUtil.h>
-#include <X11/cursorfont.h>
+#include <stdlib.h>
 
 #include "gdk.h"
-
-#include "gdkx.h"
 #include "gdkprivate.h"
-#include "gdkinputprivate.h"
 
 typedef struct _GdkPredicate  GdkPredicate;
 typedef struct _GdkErrorTrap  GdkErrorTrap;
@@ -69,18 +50,7 @@ struct _GdkErrorTrap
 /* 
  * Private function declarations
  */
-
-#ifndef HAVE_XCONVERTCASE
-static void     gdkx_XConvertCase      (KeySym        symbol,
-                                        KeySym       *lower,
-                                        KeySym       *upper);
-#define XConvertCase gdkx_XConvertCase
-#endif
-
 static void        gdk_exit_func                (void);
-static int         gdk_x_error                  (Display     *display, 
-                                                 XErrorEvent *error);
-static int         gdk_x_io_error               (Display     *display);
 
 GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
                                         GdkEvent  *event,
@@ -92,8 +62,6 @@ static int gdk_initialized = 0;                           /* 1 if the library is initialized,
                                                     * 0 otherwise.
                                                     */
 
-static gint autorepeat;
-
 static GSList *gdk_error_traps = NULL;               /* List of error traps */
 static GSList *gdk_error_trap_free_list = NULL;      /* Free list */
 
@@ -110,9 +78,168 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
 
 #endif /* G_ENABLE_DEBUG */
 
+GdkArgContext *
+gdk_arg_context_new (gpointer cb_data)
+{
+  GdkArgContext *result = g_new (GdkArgContext, 1);
+  result->tables = g_ptr_array_new ();
+  result->cb_data = cb_data;
+
+  return result;
+}
+
+void
+gdk_arg_context_destroy (GdkArgContext *context)
+{
+  g_ptr_array_free (context->tables, TRUE);
+  g_free (context);
+}
+
+void
+gdk_arg_context_add_table (GdkArgContext *context, GdkArgDesc *table)
+{
+  g_ptr_array_add (context->tables, table);
+}
+
+void
+gdk_arg_context_parse (GdkArgContext *context, gint *argc, gchar ***argv)
+{
+  int i, j, k;
+
+  /* Save a copy of the original argc and argv */
+  if (argc && argv)
+    {
+      for (i = 1; i < *argc; i++)
+       {
+         char *arg;
+         
+         if (!(*argv)[i][0] == '-' && (*argv)[i][1] == '-')
+           continue;
+         
+         arg = (*argv)[i] + 2;
+
+         /* '--' terminates list of arguments */
+         if (arg == 0)
+           {
+             (*argv)[i] = NULL;
+             break;
+           }
+             
+         for (j = 0; j < context->tables->len; j++)
+           {
+             GdkArgDesc *table = context->tables->pdata[j];
+             for (k = 0; table[k].name; k++)
+               {
+                 switch (table[k].type)
+                   {
+                   case GDK_ARG_STRING:
+                   case GDK_ARG_CALLBACK:
+                   case GDK_ARG_INT:
+                     {
+                       int len = strlen (table[k].name);
+                       
+                       if (strncmp (arg, table[k].name, len) == 0 &&
+                           (arg[len] == '=' || argc[len] == 0))
+                         {
+                           char *value = NULL;
+
+                           (*argv)[i] = NULL;
+
+                           if (arg[len] == '=')
+                             value = arg + len + 1;
+                           else if (i < *argc - 1)
+                             {
+                               value = (*argv)[i + 1];
+                               (*argv)[i+1] = NULL;
+                               i++;
+                             }
+                           else
+                             value = "";
+
+                           switch (table[k].type)
+                             {
+                             case GDK_ARG_STRING:
+                               *(gchar **)table[k].location = g_strdup (value);
+                               break;
+                             case GDK_ARG_INT:
+                               *(gint *)table[k].location = atoi (value);
+                               break;
+                             case GDK_ARG_CALLBACK:
+                               (*table[k].callback)(table[k].name, value, context->cb_data);
+                               break;
+                             default:
+                             }
+
+                           goto next_arg;
+                         }
+                       break;
+                     }
+                   case GDK_ARG_BOOL:
+                   case GDK_ARG_NOBOOL:
+                     if (strcmp (arg, table[k].name) == 0)
+                       {
+                         (*argv)[i] = NULL;
+                         
+                         *(gboolean *)table[k].location = (table[k].type == GDK_ARG_BOOL) ? TRUE : FALSE;
+                         goto next_arg;
+                       }
+                   }
+               }
+           }
+       next_arg:
+       }
+         
+      for (i = 1; i < *argc; i++)
+       {
+         for (k = i; k < *argc; k++)
+           if ((*argv)[k] != NULL)
+             break;
+         
+         if (k > i)
+           {
+             k -= i;
+             for (j = i + k; j < *argc; j++)
+               (*argv)[j-k] = (*argv)[j];
+             *argc -= k;
+           }
+       }
+    }
+}
+
+static void
+gdk_arg_debug_cb (const char *key, const char *value, gpointer user_data)
+{
+  gdk_debug_flags |= g_parse_debug_string (value,
+                                          (GDebugKey *) gdk_debug_keys,
+                                          gdk_ndebug_keys);
+}
+
+static void
+gdk_arg_no_debug_cb (const char *key, const char *value, gpointer user_data)
+{
+  gdk_debug_flags &= ~g_parse_debug_string (value,
+                                           (GDebugKey *) gdk_debug_keys,
+                                           gdk_ndebug_keys);
+}
+
+static void
+gdk_arg_name_cb (const char *key, const char *value, gpointer user_data)
+{
+  g_set_prgname (value);
+}
+
+static GdkArgDesc gdk_args[] = {
+  { "name",         GDK_ARG_STRING,   NULL, gdk_arg_name_cb     },
+#ifdef G_ENABLE_DEBUG
+  { "gdk-debug",    GDK_ARG_CALLBACK, NULL, gdk_arg_debug_cb    },
+  { "gdk-no-debug", GDK_ARG_CALLBACK, NULL, gdk_arg_no_debug_cb },
+#endif /* G_ENABLE_DEBUG */
+  { NULL }
+};
+
 /*
  *--------------------------------------------------------------
- * gdk_init_heck
+ * gdk_init_check
  *
  *   Initialize the library for use.
  *
@@ -133,15 +260,14 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
  */
 
 gboolean
-gdk_init_check (int     *argc,
+gdk_init_check (int    *argc,
                char ***argv)
 {
-  XKeyboardState keyboard_state;
-  gint synchronize;
-  gint i, j, k;
-  XClassHint *class_hint;
   gchar **argv_orig = NULL;
   gint argc_orig = 0;
+  GdkArgContext *arg_context;
+  gboolean result;
+  int i;
   
   if (gdk_initialized)
     return TRUE;
@@ -157,27 +283,7 @@ gdk_init_check (int         *argc,
       for (i = 0; i < argc_orig; i++)
        argv_orig[i] = g_strdup ((*argv)[i]);
       argv_orig[argc_orig] = NULL;
-    }
-  
-  gdk_display_name = NULL;
-  
-  XSetErrorHandler (gdk_x_error);
-  XSetIOErrorHandler (gdk_x_io_error);
-  
-  synchronize = FALSE;
-  
-#ifdef G_ENABLE_DEBUG
-  {
-    gchar *debug_string = getenv("GDK_DEBUG");
-    if (debug_string != NULL)
-      gdk_debug_flags = g_parse_debug_string (debug_string,
-                                             (GDebugKey *) gdk_debug_keys,
-                                             gdk_ndebug_keys);
-  }
-#endif /* G_ENABLE_DEBUG */
-  
-  if (argc && argv)
-    {
+
       if (*argc > 0)
        {
          gchar *d;
@@ -188,213 +294,35 @@ gdk_init_check (int       *argc,
          else
            g_set_prgname ((*argv)[0]);
        }
-      
-      for (i = 1; i < *argc;)
-       {
-#ifdef G_ENABLE_DEBUG    
-         if ((strcmp ("--gdk-debug", (*argv)[i]) == 0) ||
-             (strncmp ("--gdk-debug=", (*argv)[i], 12) == 0))
-           {
-             gchar *equal_pos = strchr ((*argv)[i], '=');
-             
-             if (equal_pos != NULL)
-               {
-                 gdk_debug_flags |= g_parse_debug_string (equal_pos+1,
-                                                          (GDebugKey *) gdk_debug_keys,
-                                                          gdk_ndebug_keys);
-               }
-             else if ((i + 1) < *argc && (*argv)[i + 1])
-               {
-                 gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
-                                                          (GDebugKey *) gdk_debug_keys,
-                                                          gdk_ndebug_keys);
-                 (*argv)[i] = NULL;
-                 i += 1;
-               }
-             (*argv)[i] = NULL;
-           }
-         else if ((strcmp ("--gdk-no-debug", (*argv)[i]) == 0) ||
-                  (strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0))
-           {
-             gchar *equal_pos = strchr ((*argv)[i], '=');
-             
-             if (equal_pos != NULL)
-               {
-                 gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1,
-                                                           (GDebugKey *) gdk_debug_keys,
-                                                           gdk_ndebug_keys);
-               }
-             else if ((i + 1) < *argc && (*argv)[i + 1])
-               {
-                 gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
-                                                           (GDebugKey *) gdk_debug_keys,
-                                                           gdk_ndebug_keys);
-                 (*argv)[i] = NULL;
-                 i += 1;
-               }
-             (*argv)[i] = NULL;
-           }
-         else 
-#endif /* G_ENABLE_DEBUG */
-           if (strcmp ("--display", (*argv)[i]) == 0)
-             {
-               (*argv)[i] = NULL;
-               
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   gdk_display_name = g_strdup ((*argv)[i + 1]);
-                   (*argv)[i + 1] = NULL;
-                   i += 1;
-                 }
-             }
-           else if (strcmp ("--sync", (*argv)[i]) == 0)
-             {
-               (*argv)[i] = NULL;
-               synchronize = TRUE;
-             }
-           else if (strcmp ("--no-xshm", (*argv)[i]) == 0)
-             {
-               (*argv)[i] = NULL;
-               gdk_use_xshm = FALSE;
-             }
-           else if (strcmp ("--name", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   g_set_prgname ((*argv)[i]);
-                   (*argv)[i] = NULL;
-                 }
-             }
-           else if (strcmp ("--class", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   gdk_progclass = (*argv)[i];
-                   (*argv)[i] = NULL;
-                 }
-             }
-#ifdef XINPUT_GXI
-           else if (strcmp ("--gxid_host", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   gdk_input_gxid_host = ((*argv)[i]);
-                   (*argv)[i] = NULL;
-                 }
-             }
-           else if (strcmp ("--gxid_port", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   gdk_input_gxid_port = atoi ((*argv)[i]);
-                   (*argv)[i] = NULL;
-                 }
-             }
-#endif
-#ifdef USE_XIM
-           else if (strcmp ("--xim-preedit", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   if (strcmp ("none", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
-                   else if (strcmp ("nothing", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
-                   else if (strcmp ("area", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
-                   else if (strcmp ("position", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
-                   else if (strcmp ("callbacks", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
-                   (*argv)[i] = NULL;
-                 }
-             }
-           else if (strcmp ("--xim-status", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   if (strcmp ("none", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_STATUS_NONE);
-                   else if (strcmp ("nothing", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
-                   else if (strcmp ("area", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_STATUS_AREA);
-                   else if (strcmp ("callbacks", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
-                   (*argv)[i] = NULL;
-                 }
-             }
-#endif
-         
-         i += 1;
-       }
-      
-      for (i = 1; i < *argc; i++)
-       {
-         for (k = i; k < *argc; k++)
-           if ((*argv)[k] != NULL)
-             break;
-         
-         if (k > i)
-           {
-             k -= i;
-             for (j = i + k; j < *argc; j++)
-               (*argv)[j-k] = (*argv)[j];
-             *argc -= k;
-           }
-       }
-    }
-  else
-    {
-      g_set_prgname ("<unknown>");
     }
+
   
-  GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
-  
-  gdk_display = XOpenDisplay (gdk_display_name);
-  if (!gdk_display)
-    return FALSE;
-  
-  if (synchronize)
-    XSynchronize (gdk_display, True);
-  
-  gdk_screen = DefaultScreen (gdk_display);
-  gdk_root_window = RootWindow (gdk_display, gdk_screen);
-  
-  gdk_leader_window = XCreateSimpleWindow(gdk_display, gdk_root_window,
-                                         10, 10, 10, 10, 0, 0 , 0);
-  class_hint = XAllocClassHint();
-  class_hint->res_name = g_get_prgname ();
-  if (gdk_progclass == NULL)
-    {
-      gdk_progclass = g_strdup (g_get_prgname ());
-      gdk_progclass[0] = toupper (gdk_progclass[0]);
-    }
-  class_hint->res_class = gdk_progclass;
-  XmbSetWMProperties (gdk_display, gdk_leader_window,
-                      NULL, NULL, argv_orig, argc_orig, 
-                      NULL, NULL, class_hint);
-  XFree (class_hint);
+#ifdef G_ENABLE_DEBUG
+  {
+    gchar *debug_string = getenv("GDK_DEBUG");
+    if (debug_string != NULL)
+      gdk_debug_flags = g_parse_debug_string (debug_string,
+                                             (GDebugKey *) gdk_debug_keys,
+                                             gdk_ndebug_keys);
+  }
+#endif /* G_ENABLE_DEBUG */
+
+  arg_context = gdk_arg_context_new (NULL);
+  gdk_arg_context_add_table (arg_context, gdk_args);
+  gdk_arg_context_add_table (arg_context, _gdk_windowing_args);
+  gdk_arg_context_parse (arg_context, argc, argv);
+  gdk_arg_context_destroy (arg_context);
   
+  GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
+
+  result = _gdk_windowing_init_check (argc_orig, argv_orig);
+
   for (i = 0; i < argc_orig; i++)
     g_free(argv_orig[i]);
   g_free(argv_orig);
-  
-  gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", False);
-  gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", False);
-  gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", False);
-  gdk_wm_window_protocols[0] = gdk_wm_delete_window;
-  gdk_wm_window_protocols[1] = gdk_wm_take_focus;
-  gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False);
-  
-  XGetKeyboardControl (gdk_display, &keyboard_state);
-  autorepeat = keyboard_state.global_auto_repeat;
+
+  if (!result)
+    return FALSE;
   
   g_atexit (gdk_exit_func);
   
@@ -451,377 +379,6 @@ gdk_exit (gint errorcode)
   exit (errorcode);
 }
 
-void
-gdk_set_use_xshm (gint use_xshm)
-{
-  gdk_use_xshm = use_xshm;
-}
-
-gint
-gdk_get_use_xshm (void)
-{
-  return gdk_use_xshm;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_pointer_grab
- *
- *   Grabs the pointer to a specific window
- *
- * Arguments:
- *   "window" is the window which will receive the grab
- *   "owner_events" specifies whether events will be reported as is,
- *     or relative to "window"
- *   "event_mask" masks only interesting events
- *   "confine_to" limits the cursor movement to the specified window
- *   "cursor" changes the cursor for the duration of the grab
- *   "time" specifies the time
- *
- * Results:
- *
- * Side effects:
- *   requires a corresponding call to gdk_pointer_ungrab
- *
- *--------------------------------------------------------------
- */
-
-gint
-gdk_pointer_grab (GdkWindow *    window,
-                 gint            owner_events,
-                 GdkEventMask    event_mask,
-                 GdkWindow *     confine_to,
-                 GdkCursor *     cursor,
-                 guint32         time)
-{
-  gint return_val;
-  GdkCursorPrivate *cursor_private;
-  guint xevent_mask;
-  Window xwindow;
-  Window xconfine_to;
-  Cursor xcursor;
-  int i;
-  
-  g_return_val_if_fail (window != NULL, 0);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
-  g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
-  
-  cursor_private = (GdkCursorPrivate*) cursor;
-  
-  xwindow = GDK_DRAWABLE_XID (window);
-  
-  if (!confine_to || GDK_DRAWABLE_DESTROYED (confine_to))
-    xconfine_to = None;
-  else
-    xconfine_to = GDK_DRAWABLE_XID (confine_to);
-  
-  if (!cursor)
-    xcursor = None;
-  else
-    xcursor = cursor_private->xcursor;
-  
-  
-  xevent_mask = 0;
-  for (i = 0; i < gdk_nevent_masks; i++)
-    {
-      if (event_mask & (1 << (i + 1)))
-       xevent_mask |= gdk_event_mask_table[i];
-    }
-  
-  if (gdk_input_vtable.grab_pointer)
-    return_val = gdk_input_vtable.grab_pointer (window,
-                                               owner_events,
-                                               event_mask,
-                                               confine_to,
-                                               time);
-  else
-    return_val = Success;
-  
-  if (return_val == Success)
-    {
-      if (!GDK_DRAWABLE_DESTROYED (window))
-       return_val = XGrabPointer (GDK_DRAWABLE_XDISPLAY (window),
-                                  xwindow,
-                                  owner_events,
-                                  xevent_mask,
-                                  GrabModeAsync, GrabModeAsync,
-                                  xconfine_to,
-                                  xcursor,
-                                  time);
-      else
-       return_val = AlreadyGrabbed;
-    }
-  
-  if (return_val == GrabSuccess)
-    gdk_xgrab_window = (GdkWindowPrivate *)window;
-  
-  return return_val;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_pointer_ungrab
- *
- *   Releases any pointer grab
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-void
-gdk_pointer_ungrab (guint32 time)
-{
-  if (gdk_input_vtable.ungrab_pointer)
-    gdk_input_vtable.ungrab_pointer (time);
-  
-  XUngrabPointer (gdk_display, time);
-  gdk_xgrab_window = NULL;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_pointer_is_grabbed
- *
- *   Tell wether there is an active x pointer grab in effect
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-gint
-gdk_pointer_is_grabbed (void)
-{
-  return gdk_xgrab_window != NULL;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_keyboard_grab
- *
- *   Grabs the keyboard to a specific window
- *
- * Arguments:
- *   "window" is the window which will receive the grab
- *   "owner_events" specifies whether events will be reported as is,
- *     or relative to "window"
- *   "time" specifies the time
- *
- * Results:
- *
- * Side effects:
- *   requires a corresponding call to gdk_keyboard_ungrab
- *
- *--------------------------------------------------------------
- */
-
-gint
-gdk_keyboard_grab (GdkWindow *    window,
-                  gint            owner_events,
-                  guint32         time)
-{
-  g_return_val_if_fail (window != NULL, 0);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    return XGrabKeyboard (GDK_DRAWABLE_XDISPLAY (window),
-                         GDK_DRAWABLE_XID (window),
-                         owner_events,
-                         GrabModeAsync, GrabModeAsync,
-                         time);
-  else
-    return AlreadyGrabbed;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_keyboard_ungrab
- *
- *   Releases any keyboard grab
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-void
-gdk_keyboard_ungrab (guint32 time)
-{
-  XUngrabKeyboard (gdk_display, time);
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_screen_width
- *
- *   Return the width of the screen.
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-gint
-gdk_screen_width (void)
-{
-  gint return_val;
-  
-  return_val = DisplayWidth (gdk_display, gdk_screen);
-  
-  return return_val;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_screen_height
- *
- *   Return the height of the screen.
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-gint
-gdk_screen_height (void)
-{
-  gint return_val;
-  
-  return_val = DisplayHeight (gdk_display, gdk_screen);
-  
-  return return_val;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_screen_width_mm
- *
- *   Return the width of the screen in millimeters.
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-gint
-gdk_screen_width_mm (void)
-{
-  gint return_val;
-  
-  return_val = DisplayWidthMM (gdk_display, gdk_screen);
-  
-  return return_val;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_screen_height
- *
- *   Return the height of the screen in millimeters.
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-gint
-gdk_screen_height_mm (void)
-{
-  gint return_val;
-  
-  return_val = DisplayHeightMM (gdk_display, gdk_screen);
-  
-  return return_val;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_set_sm_client_id
- *
- *   Set the SM_CLIENT_ID property on the WM_CLIENT_LEADER window
- *   so that the window manager can save our state using the
- *   X11R6 ICCCM session management protocol. A NULL value should 
- *   be set following disconnection from the session manager to
- *   remove the SM_CLIENT_ID property.
- *
- * Arguments:
- * 
- *   "sm_client_id" specifies the client id assigned to us by the
- *   session manager or NULL to remove the property.
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-void
-gdk_set_sm_client_id (const gchar* sm_client_id)
-{
-  if (sm_client_id && strcmp (sm_client_id, ""))
-    {
-      XChangeProperty (gdk_display, gdk_leader_window,
-                      gdk_atom_intern ("SM_CLIENT_ID", FALSE),
-                      XA_STRING, 8, PropModeReplace,
-                      sm_client_id, strlen(sm_client_id));
-    }
-  else
-     XDeleteProperty (gdk_display, gdk_leader_window,
-                     gdk_atom_intern ("SM_CLIENT_ID", FALSE));
-}
-
-void
-gdk_key_repeat_disable (void)
-{
-  XAutoRepeatOff (gdk_display);
-}
-
-void
-gdk_key_repeat_restore (void)
-{
-  if (autorepeat)
-    XAutoRepeatOn (gdk_display);
-  else
-    XAutoRepeatOff (gdk_display);
-}
-
-
-void
-gdk_beep (void)
-{
-  XBell(gdk_display, 0);
-}
-
 /*
  *--------------------------------------------------------------
  * gdk_exit_func
@@ -863,120 +420,10 @@ gdk_exit_func (void)
       gdk_input_exit ();
       gdk_key_repeat_restore ();
       
-      XCloseDisplay (gdk_display);
       gdk_initialized = 0;
     }
 }
 
-/*
- *--------------------------------------------------------------
- * gdk_x_error
- *
- *   The X error handling routine.
- *
- * Arguments:
- *   "display" is the X display the error orignated from.
- *   "error" is the XErrorEvent that we are handling.
- *
- * Results:
- *   Either we were expecting some sort of error to occur,
- *   in which case we set the "gdk_error_code" flag, or this
- *   error was unexpected, in which case we will print an
- *   error message and exit. (Since trying to continue will
- *   most likely simply lead to more errors).
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-static int
-gdk_x_error (Display    *display,
-            XErrorEvent *error)
-{
-  if (error->error_code)
-    {
-      if (gdk_error_warnings)
-       {
-         char buf[64];
-         
-         XGetErrorText (display, error->error_code, buf, 63);
-
-#ifdef G_ENABLE_DEBUG    
-         g_error ("%s\n  serial %ld error_code %d request_code %d minor_code %d\n", 
-                  buf, 
-                  error->serial, 
-                  error->error_code, 
-                  error->request_code,
-                  error->minor_code);
-#else /* !G_ENABLE_DEBUG */
-         fprintf (stderr, "Gdk-ERROR **: %s\n  serial %ld error_code %d request_code %d minor_code %d\n",
-                  buf, 
-                  error->serial, 
-                  error->error_code, 
-                  error->request_code,
-                  error->minor_code);
-
-         exit(1);
-#endif /* G_ENABLE_DEBUG */
-       }
-      gdk_error_code = error->error_code;
-    }
-  
-  return 0;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_x_io_error
- *
- *   The X I/O error handling routine.
- *
- * Arguments:
- *   "display" is the X display the error orignated from.
- *
- * Results:
- *   An X I/O error basically means we lost our connection
- *   to the X server. There is not much we can do to
- *   continue, so simply print an error message and exit.
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-static int
-gdk_x_io_error (Display *display)
-{
-  /* This is basically modelled after the code in XLib. We need
-   * an explicit error handler here, so we can disable our atexit()
-   * which would otherwise cause a nice segfault.
-   * We fprintf(stderr, instead of g_warning() because g_warning()
-   * could possibly be redirected to a dialog
-   */
-  if (errno == EPIPE)
-    {
-      fprintf (stderr, "Gdk-ERROR **: X connection to %s broken (explicit kill or server shutdown).\n", gdk_display ? DisplayString (gdk_display) : gdk_get_display());
-    }
-  else
-    {
-      fprintf (stderr, "Gdk-ERROR **: Fatal IO error %d (%s) on X server %s.\n",
-              errno, g_strerror (errno),
-              gdk_display ? DisplayString (gdk_display) : gdk_get_display());
-    }
-
-  /* Disable the atexit shutdown for GDK */
-  gdk_initialized = 0;
-  
-  exit(1);
-}
-
-gchar *
-gdk_get_display (void)
-{
-  return (gchar *)XDisplayName (gdk_display_name);
-}
-
 /*************************************************************
  * gdk_error_trap_push:
  *     Push an error trap. X errors will be trapped until
@@ -1048,223 +495,182 @@ gdk_error_trap_pop (void)
   return result;
 }
 
-gint 
-gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
-                XEvent *event_send)
-{
-  Status result;
-  gint old_warnings = gdk_error_warnings;
-  
-  gdk_error_code = 0;
-  
-  gdk_error_warnings = 0;
-  result = XSendEvent (gdk_display, window, propagate, event_mask, event_send);
-  XSync (gdk_display, False);
-  gdk_error_warnings = old_warnings;
-  
-  return result && !gdk_error_code;
-}
-
 #ifndef HAVE_XCONVERTCASE
 /* compatibility function from X11R6.3, since XConvertCase is not
  * supplied by X11R5.
  */
-static void
-gdkx_XConvertCase (KeySym symbol,
-                  KeySym *lower,
-                  KeySym *upper)
+void
+gdk_keyval_convert_case (guint symbol,
+                        guint *lower,
+                        guint *upper)
 {
-  register KeySym sym = symbol;
-  
-  g_return_if_fail (lower != NULL);
-  g_return_if_fail (upper != NULL);
-  
-  *lower = sym;
-  *upper = sym;
-  
+  guint xlower = symbol;
+  guint xupper = symbol;
+
   switch (sym >> 8)
     {
 #if    defined (GDK_A) && defined (GDK_Ooblique)
     case 0: /* Latin 1 */
-      if ((sym >= GDK_A) && (sym <= GDK_Z))
-       *lower += (GDK_a - GDK_A);
-      else if ((sym >= GDK_a) && (sym <= GDK_z))
-       *upper -= (GDK_a - GDK_A);
-      else if ((sym >= GDK_Agrave) && (sym <= GDK_Odiaeresis))
-       *lower += (GDK_agrave - GDK_Agrave);
-      else if ((sym >= GDK_agrave) && (sym <= GDK_odiaeresis))
-       *upper -= (GDK_agrave - GDK_Agrave);
-      else if ((sym >= GDK_Ooblique) && (sym <= GDK_Thorn))
-       *lower += (GDK_oslash - GDK_Ooblique);
-      else if ((sym >= GDK_oslash) && (sym <= GDK_thorn))
-       *upper -= (GDK_oslash - GDK_Ooblique);
+      if ((symbol >= GDK_A) && (symbol <= GDK_Z))
+       xlower += (GDK_a - GDK_A);
+      else if ((symbol >= GDK_a) && (symbol <= GDK_z))
+       xupper -= (GDK_a - GDK_A);
+      else if ((symbol >= GDK_Agrave) && (symbol <= GDK_Odiaeresis))
+       xlower += (GDK_agrave - GDK_Agrave);
+      else if ((symbol >= GDK_agrave) && (symbol <= GDK_odiaeresis))
+       xupper -= (GDK_agrave - GDK_Agrave);
+      else if ((symbol >= GDK_Ooblique) && (symbol <= GDK_Thorn))
+       xlower += (GDK_oslash - GDK_Ooblique);
+      else if ((symbol >= GDK_oslash) && (symbol <= GDK_thorn))
+       xupper -= (GDK_oslash - GDK_Ooblique);
       break;
 #endif /* LATIN1 */
       
 #if    defined (GDK_Aogonek) && defined (GDK_tcedilla)
     case 1: /* Latin 2 */
       /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym == GDK_Aogonek)
-       *lower = GDK_aogonek;
-      else if (sym >= GDK_Lstroke && sym <= GDK_Sacute)
-       *lower += (GDK_lstroke - GDK_Lstroke);
-      else if (sym >= GDK_Scaron && sym <= GDK_Zacute)
-       *lower += (GDK_scaron - GDK_Scaron);
-      else if (sym >= GDK_Zcaron && sym <= GDK_Zabovedot)
-       *lower += (GDK_zcaron - GDK_Zcaron);
-      else if (sym == GDK_aogonek)
-       *upper = GDK_Aogonek;
-      else if (sym >= GDK_lstroke && sym <= GDK_sacute)
-       *upper -= (GDK_lstroke - GDK_Lstroke);
-      else if (sym >= GDK_scaron && sym <= GDK_zacute)
-       *upper -= (GDK_scaron - GDK_Scaron);
-      else if (sym >= GDK_zcaron && sym <= GDK_zabovedot)
-       *upper -= (GDK_zcaron - GDK_Zcaron);
-      else if (sym >= GDK_Racute && sym <= GDK_Tcedilla)
-       *lower += (GDK_racute - GDK_Racute);
-      else if (sym >= GDK_racute && sym <= GDK_tcedilla)
-       *upper -= (GDK_racute - GDK_Racute);
+      if (symbol == GDK_Aogonek)
+       xlower = GDK_aogonek;
+      else if (symbol >= GDK_Lstroke && symbol <= GDK_Sacute)
+       xlower += (GDK_lstroke - GDK_Lstroke);
+      else if (symbol >= GDK_Scaron && symbol <= GDK_Zacute)
+       xlower += (GDK_scaron - GDK_Scaron);
+      else if (symbol >= GDK_Zcaron && symbol <= GDK_Zabovedot)
+       xlower += (GDK_zcaron - GDK_Zcaron);
+      else if (symbol == GDK_aogonek)
+       xupper = GDK_Aogonek;
+      else if (symbol >= GDK_lstroke && symbol <= GDK_sacute)
+       xupper -= (GDK_lstroke - GDK_Lstroke);
+      else if (symbol >= GDK_scaron && symbol <= GDK_zacute)
+       xupper -= (GDK_scaron - GDK_Scaron);
+      else if (symbol >= GDK_zcaron && symbol <= GDK_zabovedot)
+       xupper -= (GDK_zcaron - GDK_Zcaron);
+      else if (symbol >= GDK_Racute && symbol <= GDK_Tcedilla)
+       xlower += (GDK_racute - GDK_Racute);
+      else if (symbol >= GDK_racute && symbol <= GDK_tcedilla)
+       xupper -= (GDK_racute - GDK_Racute);
       break;
 #endif /* LATIN2 */
       
 #if    defined (GDK_Hstroke) && defined (GDK_Cabovedot)
     case 2: /* Latin 3 */
       /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym >= GDK_Hstroke && sym <= GDK_Hcircumflex)
-       *lower += (GDK_hstroke - GDK_Hstroke);
-      else if (sym >= GDK_Gbreve && sym <= GDK_Jcircumflex)
-       *lower += (GDK_gbreve - GDK_Gbreve);
-      else if (sym >= GDK_hstroke && sym <= GDK_hcircumflex)
-       *upper -= (GDK_hstroke - GDK_Hstroke);
-      else if (sym >= GDK_gbreve && sym <= GDK_jcircumflex)
-       *upper -= (GDK_gbreve - GDK_Gbreve);
-      else if (sym >= GDK_Cabovedot && sym <= GDK_Scircumflex)
-       *lower += (GDK_cabovedot - GDK_Cabovedot);
-      else if (sym >= GDK_cabovedot && sym <= GDK_scircumflex)
-       *upper -= (GDK_cabovedot - GDK_Cabovedot);
+      if (symbol >= GDK_Hstroke && symbol <= GDK_Hcircumflex)
+       xlower += (GDK_hstroke - GDK_Hstroke);
+      else if (symbol >= GDK_Gbreve && symbol <= GDK_Jcircumflex)
+       xlower += (GDK_gbreve - GDK_Gbreve);
+      else if (symbol >= GDK_hstroke && symbol <= GDK_hcircumflex)
+       xupper -= (GDK_hstroke - GDK_Hstroke);
+      else if (symbol >= GDK_gbreve && symbol <= GDK_jcircumflex)
+       xupper -= (GDK_gbreve - GDK_Gbreve);
+      else if (symbol >= GDK_Cabovedot && symbol <= GDK_Scircumflex)
+       xlower += (GDK_cabovedot - GDK_Cabovedot);
+      else if (symbol >= GDK_cabovedot && symbol <= GDK_scircumflex)
+       xupper -= (GDK_cabovedot - GDK_Cabovedot);
       break;
 #endif /* LATIN3 */
       
 #if    defined (GDK_Rcedilla) && defined (GDK_Amacron)
     case 3: /* Latin 4 */
       /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym >= GDK_Rcedilla && sym <= GDK_Tslash)
-       *lower += (GDK_rcedilla - GDK_Rcedilla);
-      else if (sym >= GDK_rcedilla && sym <= GDK_tslash)
-       *upper -= (GDK_rcedilla - GDK_Rcedilla);
-      else if (sym == GDK_ENG)
-       *lower = GDK_eng;
-      else if (sym == GDK_eng)
-       *upper = GDK_ENG;
-      else if (sym >= GDK_Amacron && sym <= GDK_Umacron)
-       *lower += (GDK_amacron - GDK_Amacron);
-      else if (sym >= GDK_amacron && sym <= GDK_umacron)
-       *upper -= (GDK_amacron - GDK_Amacron);
+      if (symbol >= GDK_Rcedilla && symbol <= GDK_Tslash)
+       xlower += (GDK_rcedilla - GDK_Rcedilla);
+      else if (symbol >= GDK_rcedilla && symbol <= GDK_tslash)
+       xupper -= (GDK_rcedilla - GDK_Rcedilla);
+      else if (symbol == GDK_ENG)
+       xlower = GDK_eng;
+      else if (symbol == GDK_eng)
+       xupper = GDK_ENG;
+      else if (symbol >= GDK_Amacron && symbol <= GDK_Umacron)
+       xlower += (GDK_amacron - GDK_Amacron);
+      else if (symbol >= GDK_amacron && symbol <= GDK_umacron)
+       xupper -= (GDK_amacron - GDK_Amacron);
       break;
 #endif /* LATIN4 */
       
 #if    defined (GDK_Serbian_DJE) && defined (GDK_Cyrillic_yu)
     case 6: /* Cyrillic */
       /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym >= GDK_Serbian_DJE && sym <= GDK_Serbian_DZE)
-       *lower -= (GDK_Serbian_DJE - GDK_Serbian_dje);
-      else if (sym >= GDK_Serbian_dje && sym <= GDK_Serbian_dze)
-       *upper += (GDK_Serbian_DJE - GDK_Serbian_dje);
-      else if (sym >= GDK_Cyrillic_YU && sym <= GDK_Cyrillic_HARDSIGN)
-       *lower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
-      else if (sym >= GDK_Cyrillic_yu && sym <= GDK_Cyrillic_hardsign)
-       *upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
+      if (symbol >= GDK_Serbian_DJE && symbol <= GDK_Serbian_DZE)
+       xlower -= (GDK_Serbian_DJE - GDK_Serbian_dje);
+      else if (symbol >= GDK_Serbian_dje && symbol <= GDK_Serbian_dze)
+       xupper += (GDK_Serbian_DJE - GDK_Serbian_dje);
+      else if (symbol >= GDK_Cyrillic_YU && symbol <= GDK_Cyrillic_HARDSIGN)
+       xlower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
+      else if (symbol >= GDK_Cyrillic_yu && symbol <= GDK_Cyrillic_hardsign)
+       xupper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
       break;
 #endif /* CYRILLIC */
       
 #if    defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma)
     case 7: /* Greek */
       /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym >= GDK_Greek_ALPHAaccent && sym <= GDK_Greek_OMEGAaccent)
-       *lower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
-      else if (sym >= GDK_Greek_alphaaccent && sym <= GDK_Greek_omegaaccent &&
-              sym != GDK_Greek_iotaaccentdieresis &&
-              sym != GDK_Greek_upsilonaccentdieresis)
-       *upper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
-      else if (sym >= GDK_Greek_ALPHA && sym <= GDK_Greek_OMEGA)
-       *lower += (GDK_Greek_alpha - GDK_Greek_ALPHA);
-      else if (sym >= GDK_Greek_alpha && sym <= GDK_Greek_omega &&
-              sym != GDK_Greek_finalsmallsigma)
-       *upper -= (GDK_Greek_alpha - GDK_Greek_ALPHA);
+      if (symbol >= GDK_Greek_ALPHAaccent && symbol <= GDK_Greek_OMEGAaccent)
+       xlower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
+      else if (symbol >= GDK_Greek_alphaaccent && symbol <= GDK_Greek_omegaaccent &&
+              symbol != GDK_Greek_iotaaccentdieresis &&
+              symbol != GDK_Greek_upsilonaccentdieresis)
+       xupper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
+      else if (symbol >= GDK_Greek_ALPHA && symbol <= GDK_Greek_OMEGA)
+       xlower += (GDK_Greek_alpha - GDK_Greek_ALPHA);
+      else if (symbol >= GDK_Greek_alpha && symbol <= GDK_Greek_omega &&
+              symbol != GDK_Greek_finalsmallsigma)
+       xupper -= (GDK_Greek_alpha - GDK_Greek_ALPHA);
       break;
 #endif /* GREEK */
     }
-}
-#endif
 
-gchar*
-gdk_keyval_name (guint       keyval)
-{
-  return XKeysymToString (keyval);
+  if (lower)
+    *lower = xlower;
+  if (upper)
+    *upper = xupper;
 }
+#endif
 
 guint
-gdk_keyval_from_name (const gchar *keyval_name)
+gdk_keyval_to_upper (guint keyval)
 {
-  g_return_val_if_fail (keyval_name != NULL, 0);
+  guint result;
   
-  return XStringToKeysym (keyval_name);
-}
+  gdk_keyval_convert_case (keyval, NULL, &result);
 
-guint
-gdk_keyval_to_upper (guint       keyval)
-{
-  if (keyval)
-    {
-      KeySym lower_val = 0;
-      KeySym upper_val = 0;
-      
-      XConvertCase (keyval, &lower_val, &upper_val);
-      return upper_val;
-    }
-  return 0;
+  return result;
 }
 
 guint
-gdk_keyval_to_lower (guint       keyval)
+gdk_keyval_to_lower (guint keyval)
 {
-  if (keyval)
-    {
-      KeySym lower_val = 0;
-      KeySym upper_val = 0;
-      
-      XConvertCase (keyval, &lower_val, &upper_val);
-      return lower_val;
-    }
-  return 0;
+  guint result;
+  
+  gdk_keyval_convert_case (keyval, &result, NULL);
+
+  return result;
 }
 
 gboolean
-gdk_keyval_is_upper (guint       keyval)
+gdk_keyval_is_upper (guint keyval)
 {
   if (keyval)
     {
-      KeySym lower_val = 0;
-      KeySym upper_val = 0;
+      guint upper_val = 0;
       
-      XConvertCase (keyval, &lower_val, &upper_val);
+      gdk_keyval_convert_case (keyval, NULL, &upper_val);
       return upper_val == keyval;
     }
-  return TRUE;
+  return FALSE;
 }
 
 gboolean
-gdk_keyval_is_lower (guint       keyval)
+gdk_keyval_is_lower (guint keyval)
 {
   if (keyval)
     {
-      KeySym lower_val = 0;
-      KeySym upper_val = 0;
+      guint lower_val = 0;
       
-      XConvertCase (keyval, &lower_val, &upper_val);
+      gdk_keyval_convert_case (keyval, &lower_val, NULL);
       return lower_val == keyval;
     }
-  return TRUE;
+  return FALSE;
 }
 
 void
index 6cf20f5c88dbeb5a5128e740c635da03ece310c6..0de20ce5239cdb19ac776bed976bc7af748dd9b8 100644 (file)
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -136,12 +136,16 @@ gboolean gdk_event_send_client_message (GdkEvent    *event,
 
 /* Key values
  */
-gchar*   gdk_keyval_name                 (guint        keyval);
-guint    gdk_keyval_from_name            (const gchar *keyval_name);
-guint    gdk_keyval_to_upper             (guint        keyval);
-guint    gdk_keyval_to_lower             (guint        keyval);
-gboolean gdk_keyval_is_upper             (guint        keyval);
-gboolean gdk_keyval_is_lower             (guint        keyval);
+gchar*   gdk_keyval_name         (guint        keyval);
+guint    gdk_keyval_from_name    (const gchar *keyval_name);
+void     gdk_keyval_convert_case (guint        symbol,
+                                 guint       *lower,
+                                 guint       *upper);
+guint    gdk_keyval_to_upper     (guint        keyval);
+guint    gdk_keyval_to_lower     (guint        keyval);
+gboolean gdk_keyval_is_upper     (guint        keyval);
+gboolean gdk_keyval_is_lower     (guint        keyval);
+
 
 /* Threading
  */
diff --git a/gdk/gdkcc.c b/gdk/gdkcc.c
deleted file mode 100644 (file)
index f592fa8..0000000
+++ /dev/null
@@ -1,1721 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* Color Context module
- * Copyright 1994,1995 John L. Cwikla
- * Copyright (C) 1997 by Ripley Software Development
- * Copyright (C) 1997 by Federico Mena (port to Gtk/Gdk)
- */
-
-/* Copyright 1994,1995 John L. Cwikla
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appears in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of John L. Cwikla or
- * Wolfram Research, Inc not be used in advertising or publicity
- * pertaining to distribution of the software without specific, written
- * prior permission.  John L. Cwikla and Wolfram Research, Inc make no
- * representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- *
- * John L. Cwikla and Wolfram Research, Inc disclaim all warranties with
- * regard to this software, including all implied warranties of
- * merchantability and fitness, in no event shall John L. Cwikla or
- * Wolfram Research, Inc be liable for any special, indirect or
- * consequential damages or any damages whatsoever resulting from loss of
- * use, data or profits, whether in an action of contract, negligence or
- * other tortious action, arising out of or in connection with the use or
- * performance of this software.
- *
- * Author:
- *  John L. Cwikla
- *  X Programmer
- *  Wolfram Research Inc.
- *
- *  cwikla@wri.com
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <X11/Xlib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gdkcc.h"
-#include "gdkcolor.h"
-#include "gdkx.h"
-
-#define MAX_IMAGE_COLORS 256
-
-typedef struct _GdkColorContextPrivate GdkColorContextPrivate;
-
-struct _GdkColorContextPrivate
-{
-  GdkColorContext color_context;
-  Display *xdisplay;
-  XStandardColormap std_cmap;
-};
-
-static guint
-hash_color (gconstpointer key)
-{
-  const GdkColor *color = key;
-  
-  return (color->red * 33023 + color->green * 30013 + color->blue * 27011);
-}
-
-static gint
-compare_colors (gconstpointer a,
-               gconstpointer b)
-{
-  const GdkColor *aa = a;
-  const GdkColor *bb = b;
-  
-  return ((aa->red == bb->red) && (aa->green == bb->green) && (aa->blue == bb->blue));
-}
-
-static void
-free_hash_entry (gpointer key,
-                gpointer value,
-                gpointer user_data)
-{
-  g_free (key); /* key and value are the same GdkColor */
-}
-
-static int
-pixel_sort (const void *a, const void *b)
-{
-  return ((GdkColor *) a)->pixel - ((GdkColor *) b)->pixel;
-}
-
-/* XXX: This function does an XQueryColors() the hard way, because there is
- * no corresponding function in Gdk.
- */
-
-static void
-my_x_query_colors (GdkColormap *colormap,
-                  GdkColor    *colors,
-                  gint         ncolors)
-{
-  XColor *xcolors;
-  gint    i;
-  
-  xcolors = g_new (XColor, ncolors);
-  for (i = 0; i < ncolors; i++)
-    xcolors[i].pixel = colors[i].pixel;
-  
-  XQueryColors (gdk_display, GDK_COLORMAP_XCOLORMAP (colormap), xcolors, ncolors);
-  
-  for (i = 0; i < ncolors; i++)
-    {
-      colors[i].red   = xcolors[i].red;
-      colors[i].green = xcolors[i].green;
-      colors[i].blue  = xcolors[i].blue;
-    }
-  
-  g_free (xcolors);
-}
-
-static void
-query_colors (GdkColorContext *cc)
-{
-  gint i;
-  GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc;
-  cc->cmap = g_new (GdkColor, cc->num_colors);
-  
-  for (i = 0; i < cc->num_colors; i++)
-    cc->cmap[i].pixel = cc->clut ? cc->clut[i] : ccp->std_cmap.base_pixel + i;
-  
-  my_x_query_colors (cc->colormap, cc->cmap, cc->num_colors);
-  
-  qsort (cc->cmap, cc->num_colors, sizeof (GdkColor), pixel_sort);
-}
-
-static void
-init_bw (GdkColorContext *cc)
-{
-  GdkColor color;
-  
-  g_warning ("init_bw: failed to allocate colors, falling back to black and white");
-  
-  cc->mode = GDK_CC_MODE_BW;
-  
-  color.red = color.green = color.blue = 0;
-  
-  if (!gdk_color_alloc (cc->colormap, &color))
-    cc->black_pixel = 0;
-  else
-    cc->black_pixel = color.pixel;
-  
-  color.red = color.green = color.blue = 0xffff;
-  
-  if (!gdk_color_alloc (cc->colormap, &color))
-    cc->white_pixel = cc->black_pixel ? 0 : 1;
-  else
-    cc->white_pixel = color.pixel;
-  
-  cc->num_colors = 2;
-}
-
-static void
-init_gray (GdkColorContext *cc)
-{
-  GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc;
-  GdkColor *clrs, *cstart;
-  gint i;
-  gdouble dinc;
-  
-  cc->num_colors = GDK_VISUAL_XVISUAL (cc->visual)->map_entries;
-  
-  cc->clut = g_new (gulong, cc->num_colors);
-  cstart = g_new (GdkColor, cc->num_colors);
-  
- retrygray:
-  
-  dinc = 65535.0 / (cc->num_colors - 1);
-  
-  clrs = cstart;
-  
-  for (i = 0; i < cc->num_colors; i++)
-    {
-      clrs->red = clrs->green = clrs->blue = dinc * i;
-      
-      if (!gdk_color_alloc (cc->colormap, clrs))
-       {
-         gdk_colors_free (cc->colormap, cc->clut, i, 0);
-         
-         cc->num_colors /= 2;
-         
-         if (cc->num_colors > 1)
-           goto retrygray;
-         else
-           {
-             g_free (cc->clut);
-             cc->clut = NULL;
-             init_bw (cc);
-             g_free (cstart);
-             return;
-           }
-       }
-      
-      cc->clut[i] = clrs++->pixel;
-    }
-  
-  g_free (cstart);
-  
-  /* XXX: is this the right thing to do? */
-  ccp->std_cmap.colormap = GDK_COLORMAP_XCOLORMAP (cc->colormap);
-  ccp->std_cmap.base_pixel = 0;
-  ccp->std_cmap.red_max = cc->num_colors - 1;
-  ccp->std_cmap.green_max = 0;
-  ccp->std_cmap.blue_max = 0;
-  ccp->std_cmap.red_mult = 1;
-  ccp->std_cmap.green_mult = 0;
-  ccp->std_cmap.blue_mult = 0;
-  
-  cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen);
-  cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen);
-  
-  query_colors (cc);
-  
-  cc->mode = GDK_CC_MODE_MY_GRAY;
-}
-
-static void
-init_color (GdkColorContext *cc)
-{
-  GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc;
-  gint cubeval;
-  
-  cubeval = 1;
-  while ((cubeval * cubeval * cubeval) < GDK_VISUAL_XVISUAL (cc->visual)->map_entries)
-    cubeval++;
-  cubeval--;
-  
-  cc->num_colors = cubeval * cubeval * cubeval;
-  
-  ccp->std_cmap.red_max    = cubeval - 1;
-  ccp->std_cmap.green_max  = cubeval - 1;
-  ccp->std_cmap.blue_max   = cubeval - 1;
-  ccp->std_cmap.red_mult   = cubeval * cubeval;
-  ccp->std_cmap.green_mult = cubeval;
-  ccp->std_cmap.blue_mult  = 1;
-  ccp->std_cmap.base_pixel = 0;
-  
-  cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen);
-  cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen);
-  cc->num_colors = DisplayCells (ccp->xdisplay, gdk_screen);
-  
-  /* a CLUT for storing allocated pixel indices */
-  
-  cc->max_colors = cc->num_colors;
-  cc->clut = g_new (gulong, cc->max_colors);
-  
-  for (cubeval = 0; cubeval < cc->max_colors; cubeval++)
-    cc->clut[cubeval] = cubeval;
-  
-  query_colors (cc);
-  
-  cc->mode = GDK_CC_MODE_STD_CMAP;
-}
-
-
-static void
-init_true_color (GdkColorContext *cc)
-{
-  GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc;
-  gulong rmask, gmask, bmask;
-  
-  cc->mode = GDK_CC_MODE_TRUE;
-  
-  /* Red */
-  
-  rmask = cc->masks.red = cc->visual->red_mask;
-  
-  cc->shifts.red = 0;
-  cc->bits.red = 0;
-  
-  while (!(rmask & 1))
-    {
-      rmask >>= 1;
-      cc->shifts.red++;
-    }
-  
-  while (rmask & 1)
-    {
-      rmask >>= 1;
-      cc->bits.red++;
-    }
-  
-  /* Green */
-  
-  gmask = cc->masks.green = cc->visual->green_mask;
-  
-  cc->shifts.green = 0;
-  cc->bits.green = 0;
-  
-  while (!(gmask & 1))
-    {
-      gmask >>= 1;
-      cc->shifts.green++;
-    }
-  
-  while (gmask & 1)
-    {
-      gmask >>= 1;
-      cc->bits.green++;
-    }
-  
-  /* Blue */
-  
-  bmask = cc->masks.blue = cc->visual->blue_mask;
-  
-  cc->shifts.blue = 0;
-  cc->bits.blue = 0;
-  
-  while (!(bmask & 1))
-    {
-      bmask >>= 1;
-      cc->shifts.blue++;
-    }
-  
-  while (bmask & 1)
-    {
-      bmask >>= 1;
-      cc->bits.blue++;
-    }
-  
-  cc->num_colors = (cc->visual->red_mask | cc->visual->green_mask | cc->visual->blue_mask) + 1;
-  cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen);
-  cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen);
-}
-
-static void
-init_direct_color (GdkColorContext *cc)
-{
-  gint n, count;
-  GdkColor *clrs, *cstart;
-  gulong rval, gval, bval;
-  gulong *rtable;
-  gulong *gtable;
-  gulong *btable;
-  gdouble dinc;
-  
-  init_true_color (cc); /* for shift stuff */
-  
-  rval = cc->visual->red_mask >> cc->shifts.red;
-  gval = cc->visual->green_mask >> cc->shifts.green;
-  bval = cc->visual->blue_mask >> cc->shifts.blue;
-  
-  rtable = g_new (gulong, rval + 1);
-  gtable = g_new (gulong, gval + 1);
-  btable = g_new (gulong, bval + 1);
-  
-  cc->max_entry = MAX (rval, gval);
-  cc->max_entry = MAX (cc->max_entry, bval);
-  
-  cstart = g_new (GdkColor, cc->max_entry + 1);
-  cc->clut = g_new (gulong, cc->max_entry + 1);
-  
- retrydirect:
-  
-  for (n = 0; n < rval; n++)
-    rtable[n] = rval ? (65535.0 / rval * n) : 0;
-  
-  for (n = 0; n < gval; n++)
-    gtable[n] = gval ? (65535.0 / gval * n) : 0;
-  
-  for (n = 0; n < bval; n++)
-    btable[n] = bval ? (65535.0 / bval * n) : 0;
-  
-  cc->max_entry = MAX (rval, gval);
-  cc->max_entry = MAX (cc->max_entry, bval);
-  
-  count = 0;
-  clrs = cstart;
-  cc->num_colors = (rval + 1) * (gval + 1) * (bval + 1);
-  
-  for (n = 0; n < cc->max_entry; n++)
-    {
-      dinc = (double) n / cc->max_entry;
-      
-      clrs->red   = rtable[(int) (dinc * rval)];
-      clrs->green = gtable[(int) (dinc * gval)];
-      clrs->blue  = btable[(int) (dinc * bval)];
-      
-      if (gdk_color_alloc (cc->colormap, clrs))
-       {
-         cc->clut[count++] = clrs->pixel;
-         clrs++;
-       }
-      else
-       {
-         gdk_colors_free (cc->colormap, cc->clut, count, 0);
-         
-         rval >>= 1;
-         gval >>= 1;
-         bval >>= 1;
-         
-         cc->masks.red   = (cc->masks.red >> 1) & cc->visual->red_mask;
-         cc->masks.green = (cc->masks.green >> 1) & cc->visual->green_mask;
-         cc->masks.blue  = (cc->masks.blue >> 1) & cc->visual->blue_mask;
-         
-         cc->shifts.red++;
-         cc->shifts.green++;
-         cc->shifts.blue++;
-         
-         cc->bits.red--;
-         cc->bits.green--;
-         cc->bits.blue--;
-         
-         cc->num_colors = (rval + 1) * (gval + 1) * (bval + 1);
-         
-         if (cc->num_colors >1)
-           goto retrydirect;
-         else
-           {
-             g_free (cc->clut);
-             cc->clut = NULL;
-             init_bw (cc);
-             break;
-           }
-       }
-    }
-  
-  /* Update allocated color count; original num_colors is max_entry, which
-   * is not necessarily the same as the really allocated number of colors.
-   */
-  
-  cc->num_colors = count;
-  
-  g_free (rtable);
-  g_free (gtable);
-  g_free (btable);
-  g_free (cstart);
-}
-
-static void
-init_palette (GdkColorContext *cc)
-{
-  /* restore correct mode for this cc */
-  
-  switch (cc->visual->type)
-    {
-    case GDK_VISUAL_STATIC_GRAY:
-    case GDK_VISUAL_GRAYSCALE:
-      if (GDK_VISUAL_XVISUAL (cc->visual)->map_entries == 2)
-       cc->mode = GDK_CC_MODE_BW;
-      else
-       cc->mode = GDK_CC_MODE_MY_GRAY;
-      break;
-      
-    case GDK_VISUAL_TRUE_COLOR:
-    case GDK_VISUAL_DIRECT_COLOR:
-      cc->mode = GDK_CC_MODE_TRUE;
-      break;
-      
-    case GDK_VISUAL_STATIC_COLOR:
-    case GDK_VISUAL_PSEUDO_COLOR:
-      cc->mode = GDK_CC_MODE_STD_CMAP;
-      break;
-      
-    default:
-      cc->mode = GDK_CC_MODE_UNDEFINED;
-      break;
-    }
-  
-  /* previous palette */
-  
-  if (cc->num_palette)
-    g_free (cc->palette);
-  
-  if (cc->fast_dither)
-    g_free (cc->fast_dither);
-  
-  /* clear hash table if present */
-  
-  if (cc->color_hash)
-    {
-      g_hash_table_foreach (cc->color_hash,
-                           free_hash_entry,
-                           NULL);
-      g_hash_table_destroy (cc->color_hash);
-      cc->color_hash = NULL;
-    }
-  
-  cc->palette = NULL;
-  cc->num_palette = 0;
-  cc->fast_dither = NULL;
-}
-
-GdkColorContext *
-gdk_color_context_new (GdkVisual   *visual,
-                      GdkColormap *colormap)
-{
-  GdkColorContextPrivate *ccp;
-  gint use_private_colormap = FALSE; /* XXX: maybe restore full functionality later? */
-  GdkColorContext *cc;
-  gint retry_count;
-  GdkColormap *default_colormap;
-  
-  g_assert (visual != NULL);
-  g_assert (colormap != NULL);
-  
-  ccp = g_new (GdkColorContextPrivate, 1);
-  cc = (GdkColorContext *) ccp;
-  ccp->xdisplay = gdk_display;
-  cc->visual = visual;
-  cc->colormap = colormap;
-  cc->clut = NULL;
-  cc->cmap = NULL;
-  cc->mode = GDK_CC_MODE_UNDEFINED;
-  cc->need_to_free_colormap = FALSE;
-  
-  cc->color_hash = NULL;
-  cc->palette = NULL;
-  cc->num_palette = 0;
-  cc->fast_dither = NULL;
-  
-  default_colormap = gdk_colormap_get_system ();
-  
-  retry_count = 0;
-  
-  while (retry_count < 2)
-    {
-      /* Only create a private colormap if the visual found isn't equal
-       * to the default visual and we don't have a private colormap,
-       * -or- if we are instructed to create a private colormap (which
-       * never is the case for XmHTML).
-       */
-      
-      if (use_private_colormap
-         || ((cc->visual != gdk_visual_get_system ()) /* default visual? */
-             && (GDK_COLORMAP_XCOLORMAP (colormap) == GDK_COLORMAP_XCOLORMAP (default_colormap))))
-       {
-         g_warning ("gdk_color_context_new: non-default visual detected, "
-                    "using private colormap");
-         
-         cc->colormap = gdk_colormap_new (cc->visual, FALSE);
-         
-         cc->need_to_free_colormap = (GDK_COLORMAP_XCOLORMAP (colormap)
-                                      != GDK_COLORMAP_XCOLORMAP (default_colormap));
-       }
-      
-      switch (visual->type)
-       {
-       case GDK_VISUAL_STATIC_GRAY:
-       case GDK_VISUAL_GRAYSCALE:
-         GDK_NOTE (COLOR_CONTEXT,
-                   g_message ("gdk_color_context_new: visual class is %s\n",
-                              (visual->type == GDK_VISUAL_STATIC_GRAY) ?
-                              "GDK_VISUAL_STATIC_GRAY" :
-                              "GDK_VISUAL_GRAYSCALE"));
-         
-         if (GDK_VISUAL_XVISUAL (cc->visual)->map_entries == 2)
-           init_bw (cc);
-         else
-           init_gray (cc);
-         
-         break;
-         
-       case GDK_VISUAL_TRUE_COLOR: /* shifts */
-         GDK_NOTE (COLOR_CONTEXT,
-                   g_message ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n"));
-         
-         init_true_color (cc);
-         break;
-         
-       case GDK_VISUAL_DIRECT_COLOR: /* shifts and fake CLUT */
-         GDK_NOTE (COLOR_CONTEXT,
-                   g_message ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n"));
-         
-         init_direct_color (cc);
-         break;
-         
-       case GDK_VISUAL_STATIC_COLOR:
-       case GDK_VISUAL_PSEUDO_COLOR:
-         GDK_NOTE (COLOR_CONTEXT,
-                   g_message ("gdk_color_context_new: visual class is %s\n",
-                              (visual->type == GDK_VISUAL_STATIC_COLOR) ?
-                              "GDK_VISUAL_STATIC_COLOR" :
-                              "GDK_VISUAL_PSEUDO_COLOR"));
-         
-         init_color (cc);
-         break;
-         
-       default:
-         g_assert_not_reached ();
-       }
-      
-      if ((cc->mode == GDK_CC_MODE_BW) && (cc->visual->depth > 1))
-       {
-         use_private_colormap = TRUE;
-         retry_count++;
-       }
-      else
-       break;
-    }
-  
-  /* no. of colors allocated yet */
-  
-  cc->num_allocated = 0;
-  
-  GDK_NOTE (COLOR_CONTEXT,
-           g_message ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n",
-                      cc->visual->depth, cc->num_colors));
-  
-  return (GdkColorContext *) cc;
-}
-
-GdkColorContext *
-gdk_color_context_new_mono (GdkVisual   *visual,
-                           GdkColormap *colormap)
-{
-  GdkColorContextPrivate *ccp;
-  GdkColorContext *cc;
-  
-  g_assert (visual != NULL);
-  g_assert (colormap != NULL);
-  
-  cc = g_new (GdkColorContext, 1);
-  ccp = (GdkColorContextPrivate *) cc;
-  ccp->xdisplay = gdk_display;
-  cc->visual = visual;
-  cc->colormap = colormap;
-  cc->clut = NULL;
-  cc->cmap = NULL;
-  cc->mode = GDK_CC_MODE_UNDEFINED;
-  cc->need_to_free_colormap = FALSE;
-  
-  init_bw (cc);
-  
-  return (GdkColorContext *) cc;
-}
-
-/* This doesn't currently free black/white, hmm... */
-
-void
-gdk_color_context_free (GdkColorContext *cc)
-{
-  g_assert (cc != NULL);
-  
-  if ((cc->visual->type == GDK_VISUAL_STATIC_COLOR)
-      || (cc->visual->type == GDK_VISUAL_PSEUDO_COLOR))
-    {
-      gdk_colors_free (cc->colormap, cc->clut, cc->num_allocated, 0);
-      g_free (cc->clut);
-    }
-  else if (cc->clut != NULL)
-    {
-      gdk_colors_free (cc->colormap, cc->clut, cc->num_colors, 0);
-      g_free (cc->clut);
-    }
-  
-  if (cc->cmap != NULL)
-    g_free (cc->cmap);
-  
-  if (cc->need_to_free_colormap)
-    gdk_colormap_unref (cc->colormap);
-  
-  /* free any palette that has been associated with this GdkColorContext */
-
-  init_palette (cc);
-  
-  g_free (cc);
-}
-
-gulong
-gdk_color_context_get_pixel (GdkColorContext *cc,
-                            gushort          red,
-                            gushort          green,
-                            gushort          blue,
-                            gint            *failed)
-{
-  GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc;
-  g_assert (cc != NULL);
-  g_assert (failed != NULL);
-  
-  *failed = FALSE;
-  
-  switch (cc->mode)
-    {
-    case GDK_CC_MODE_BW:
-    {
-      gdouble value;
-      
-      value = (red / 65535.0 * 0.30
-              + green / 65535.0 * 0.59
-              + blue / 65535.0 * 0.11);
-      
-      if (value > 0.5)
-       return cc->white_pixel;
-      
-      return cc->black_pixel;
-    }
-    
-    case GDK_CC_MODE_MY_GRAY:
-    {
-      gulong ired, igreen, iblue;
-      
-      red   = red * 0.30 + green * 0.59 + blue * 0.11;
-      green = 0;
-      blue  = 0;
-      
-      if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max)
-       ired = ccp->std_cmap.red_max;
-      
-      ired *= ccp->std_cmap.red_mult;
-      
-      if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max)
-       igreen = ccp->std_cmap.green_max;
-      
-      igreen *= ccp->std_cmap.green_mult;
-      
-      if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max)
-       iblue = ccp->std_cmap.blue_max;
-      
-      iblue *= ccp->std_cmap.blue_mult;
-      
-      if (cc->clut != NULL)
-       return cc->clut[ccp->std_cmap.base_pixel + ired + igreen + iblue];
-      
-      return ccp->std_cmap.base_pixel + ired + igreen + iblue;
-    }
-    
-    case GDK_CC_MODE_TRUE:
-    {
-      gulong ired, igreen, iblue;
-      
-      if (cc->clut == NULL)
-       {
-         red   >>= 16 - cc->bits.red;
-         green >>= 16 - cc->bits.green;
-         blue  >>= 16 - cc->bits.blue;
-         
-         ired   = (red << cc->shifts.red) & cc->masks.red;
-         igreen = (green << cc->shifts.green) & cc->masks.green;
-         iblue  = (blue << cc->shifts.blue) & cc->masks.blue;
-         
-         return ired | igreen | iblue;
-       }
-      
-      ired   = cc->clut[red * cc->max_entry / 65535] & cc->masks.red;
-      igreen = cc->clut[green * cc->max_entry / 65535] & cc->masks.green;
-      iblue  = cc->clut[blue * cc->max_entry / 65535] & cc->masks.blue;
-      
-      return ired | igreen | iblue;
-    }
-    
-    case GDK_CC_MODE_PALETTE:
-      return gdk_color_context_get_pixel_from_palette (cc, &red, &green, &blue, failed);
-      
-    case GDK_CC_MODE_STD_CMAP:
-    default:
-    {
-      GdkColor color;
-      GdkColor *result = NULL;
-      
-      color.red   = red;
-      color.green = green;
-      color.blue  = blue;
-
-      if (cc->color_hash)
-       result = g_hash_table_lookup (cc->color_hash, &color);
-      
-      if (!result)
-       {
-         color.red   = red;
-         color.green = green;
-         color.blue  = blue;
-         color.pixel = 0;
-         
-         if (!gdk_color_alloc (cc->colormap, &color))
-           *failed = TRUE;
-         else
-           {
-             GdkColor *cnew;
-             
-             /* XXX: the following comment comes directly from
-              * XCC.c.  I don't know if it is relevant for
-              * gdk_color_alloc() as it is for XAllocColor()
-              * - Federico
-              */
-             /*
-              * I can't figure this out entirely, but it *is* possible
-              * that XAllocColor succeeds, even if the number of
-              * allocations we've made exceeds the number of available
-              * colors in the current colormap. And therefore it
-              * might be necessary for us to resize the CLUT.
-              */
-             
-             if (cc->num_allocated == cc->max_colors)
-               {
-                 cc->max_colors *= 2;
-                 
-                 GDK_NOTE (COLOR_CONTEXT,
-                           g_message ("gdk_color_context_get_pixel: "
-                                      "resizing CLUT to %i entries\n",
-                                      cc->max_colors));
-                 
-                 cc->clut = g_realloc (cc->clut,
-                                       cc->max_colors * sizeof (gulong));
-               }
-             
-             /* Key and value are the same color structure */
-             
-             cnew = g_new (GdkColor, 1);
-             *cnew = color;
-             
-             if (!cc->color_hash)
-               cc->color_hash = g_hash_table_new (hash_color, compare_colors);
-             g_hash_table_insert (cc->color_hash, cnew, cnew);
-             
-             cc->clut[cc->num_allocated] = color.pixel;
-             cc->num_allocated++;
-             return color.pixel;
-           }
-       }
-      
-      return result->pixel;
-    }
-    }
-}
-
-void
-gdk_color_context_get_pixels (GdkColorContext *cc,
-                             gushort         *reds,
-                             gushort         *greens,
-                             gushort         *blues,
-                             gint             ncolors,
-                             gulong          *colors,
-                             gint            *nallocated)
-{
-  gint i, k, idx;
-  gint cmapsize, ncols = 0, nopen = 0, counter = 0;
-  gint bad_alloc = FALSE;
-  gint failed[MAX_IMAGE_COLORS], allocated[MAX_IMAGE_COLORS];
-  GdkColor defs[MAX_IMAGE_COLORS], cmap[MAX_IMAGE_COLORS];
-#ifdef G_ENABLE_DEBUG  
-  gint exact_col = 0, subst_col = 0, close_col = 0, black_col = 0;
-#endif
-  g_assert (cc != NULL);
-  g_assert (reds != NULL);
-  g_assert (greens != NULL);
-  g_assert (blues != NULL);
-  g_assert (colors != NULL);
-  g_assert (nallocated != NULL);
-  
-  memset (defs, 0, MAX_IMAGE_COLORS * sizeof (GdkColor));
-  memset (failed, 0, MAX_IMAGE_COLORS * sizeof (gint));
-  memset (allocated, 0, MAX_IMAGE_COLORS * sizeof (gint));
-  
-  /* Will only have a value if used by the progressive image loader */
-  
-  ncols = *nallocated;
-  
-  *nallocated = 0;
-  
-  /* First allocate all pixels */
-  
-  for (i = 0; i < ncolors; i++)
-    {
-      /* colors[i] is only zero if the pixel at that location hasn't
-       * been allocated yet.  This is a sanity check required for proper
-       * color allocation by the progressive image loader
-       */
-      
-      if (colors[i] == 0)
-       {
-         defs[i].red   = reds[i];
-         defs[i].green = greens[i];
-         defs[i].blue  = blues[i];
-         
-         colors[i] = gdk_color_context_get_pixel (cc, reds[i], greens[i], blues[i],
-                                                  &bad_alloc);
-         
-         /* successfully allocated, store it */
-         
-         if (!bad_alloc)
-           {
-             defs[i].pixel = colors[i];
-             allocated[ncols++] = colors[i];
-           }
-         else
-           failed[nopen++] = i;
-       }
-    }
-  
-  *nallocated = ncols;
-  
-  /* all colors available, all done */
-  
-  if ((ncols == ncolors) || (nopen == 0))
-    {
-      GDK_NOTE (COLOR_CONTEXT,
-               g_message ("gdk_color_context_get_pixels: got all %i colors; "
-                          "(%i colors allocated so far)\n", ncolors, cc->num_allocated));
-      
-      return;
-    }
-  
-  /* The fun part.  We now try to allocate the colors we couldn't allocate
-   * directly.  The first step will map a color onto its nearest color
-   * that has been allocated (either by us or someone else).  If any colors
-   * remain unallocated, we map these onto the colors that we have allocated
-   * ourselves.
-   */
-  
-  /* read up to MAX_IMAGE_COLORS colors of the current colormap */
-  
-  cmapsize = MIN (cc->num_colors, MAX_IMAGE_COLORS);
-  
-  /* see if the colormap has any colors to read */
-  
-  if (cmapsize < 0)
-    {
-      g_warning ("gdk_color_context_get_pixels: oops!  no colors available, "
-                "your images will look *really* ugly.");
-      
-      return;
-    }
-  
-#ifdef G_ENABLE_DEBUG
-  exact_col = ncols;
-#endif
-  
-  /* initialize pixels */
-  
-  for (i = 0; i < cmapsize; i++)
-    {
-      cmap[i].pixel = i;
-      cmap[i].red = cmap[i].green = cmap[i].blue = 0;
-    }
-  
-  /* read the colormap */
-  
-  my_x_query_colors (cc->colormap, cmap, cmapsize);
-  
-  /* get a close match for any unallocated colors */
-  
-  counter = nopen;
-  nopen = 0;
-  idx = 0;
-  
-  do
-    {
-      gint d, j, mdist, close, ri, gi, bi;
-      gint rd, gd, bd;
-      
-      i = failed[idx];
-      
-      mdist = 0x1000000;
-      close = -1;
-      
-      /* Store these vals.  Small performance increase as this skips three
-       * indexing operations in the loop code.
-       */
-      
-      ri = reds[i];
-      gi = greens[i];
-      bi = blues[i];
-      
-      /* Walk all colors in the colormap and see which one is the
-       * closest.  Uses plain least squares.
-       */
-      
-      for (j = 0; (j < cmapsize) && (mdist != 0); j++)
-       {
-         /* Don't replace these by shifts; the sign may get clobbered */
-         
-         rd = (ri - cmap[j].red) / 256;
-         gd = (gi - cmap[j].green) / 256;
-         bd = (bi - cmap[j].blue) / 256;
-         
-         d = rd * rd + gd * gd + bd * bd;
-         
-         if (d < mdist)
-           {
-             close = j;
-             mdist = d;
-           }
-       }
-      
-      if (close != -1)
-       {
-         rd = cmap[close].red;
-         gd = cmap[close].green;
-         bd = cmap[close].blue;
-         
-         /* allocate */
-         
-         colors[i] = gdk_color_context_get_pixel (cc, rd, gd, bd, &bad_alloc);
-         
-         /* store */
-         
-         if (!bad_alloc)
-           {
-             defs[i] = cmap[close];
-             defs[i].pixel = colors[i];
-             allocated[ncols++] = colors[i];
-#ifdef G_ENABLE_DEBUG
-             close_col++;
-#endif
-           } else
-             failed[nopen++] = i;
-       } else
-         failed[nopen++] = i;
-      /* deal with in next stage if allocation failed */
-    }
-  while (++idx < counter);
-  
-  *nallocated = ncols;
-  
-  /* This is the maximum no. of allocated colors.  See also the nopen == 0
-   * note above.
-   */
-  
-  if ((ncols == ncolors) || (nopen == 0))
-    {
-      GDK_NOTE (COLOR_CONTEXT,
-               g_message ("gdk_color_context_get_pixels: got %i colors, %i exact and "
-                          "%i close (%i colors allocated so far)\n",
-                          ncolors, exact_col, close_col, cc->num_allocated));
-      
-      return;
-    }
-  
-  /* Now map any remaining unallocated pixels into the colors we did get */
-  
-  idx = 0;
-  
-  do
-    {
-      gint d, mdist, close, ri, gi, bi;
-      gint j, rd, gd, bd;
-      
-      i = failed[idx];
-      
-      mdist = 0x1000000;
-      close = -1;
-      
-      /* store */
-      
-      ri = reds[i];
-      gi = greens[i];
-      bi = blues[i];
-      
-      /* search allocated colors */
-      
-      for (j = 0; (j < ncols) && (mdist != 0); j++)
-       {
-         k = allocated[j];
-         
-         /* Don't replace these by shifts; the sign may get clobbered */
-         
-         rd = (ri - defs[k].red) / 256;
-         gd = (gi - defs[k].green) / 256;
-         bd = (bi - defs[k].blue) / 256;
-         
-         d = rd * rd + gd * gd + bd * bd;
-         
-         if (d < mdist)
-           {
-             close = k;
-             mdist = d;
-           }
-       }
-      
-      if (close < 0)
-       {
-         /* too bad, map to black */
-         
-         defs[i].pixel = cc->black_pixel;
-         defs[i].red = defs[i].green = defs[i].blue = 0;
-#ifdef G_ENABLE_DEBUG
-         black_col++;
-#endif
-       }
-      else
-       {
-         defs[i] = defs[close];
-#ifdef G_ENABLE_DEBUG
-         subst_col++;
-#endif
-       }
-      
-      colors[i] = defs[i].pixel;
-    }
-  while (++idx < nopen);
-  
-  GDK_NOTE (COLOR_CONTEXT,
-           g_message ("gdk_color_context_get_pixels: got %i colors, %i exact, %i close, "
-                      "%i substituted, %i to black (%i colors allocated so far)\n",
-                      ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated));
-}
-
-void
-gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
-                                         gushort         *reds,
-                                         gushort         *greens,
-                                         gushort         *blues,
-                                         gint             ncolors,
-                                         gint            *used,
-                                         gulong          *colors,
-                                         gint            *nallocated)
-{
-  gint i, k, idx;
-  gint cmapsize, ncols = 0, nopen = 0, counter = 0;
-  gint bad_alloc = FALSE;
-  gint failed[MAX_IMAGE_COLORS], allocated[MAX_IMAGE_COLORS];
-  GdkColor defs[MAX_IMAGE_COLORS], cmap[MAX_IMAGE_COLORS];
-#ifdef G_ENABLE_DEBUG  
-  gint exact_col = 0, subst_col = 0, close_col = 0, black_col = 0;
-#endif  
-  
-  g_assert (cc != NULL);
-  g_assert (reds != NULL);
-  g_assert (greens != NULL);
-  g_assert (blues != NULL);
-  g_assert (used != NULL);
-  g_assert (colors != NULL);
-  g_assert (nallocated != NULL);
-  
-  memset (defs, 0, MAX_IMAGE_COLORS * sizeof (GdkColor));
-  memset (failed, 0, MAX_IMAGE_COLORS * sizeof (gint));
-  memset (allocated, 0, MAX_IMAGE_COLORS * sizeof (gint));
-  
-  /* Will only have a value if used by the progressive image loader */
-  
-  ncols = *nallocated;
-  
-  *nallocated = 0;
-  
-  /* First allocate all pixels */
-  
-  for (i = 0; i < ncolors; i++)
-    {
-      /* used[i] is only -1 if the pixel at that location hasn't
-       * been allocated yet.  This is a sanity check required for proper
-       * color allocation by the progressive image loader.
-       * When colors[i] == 0 it indicates the slot is available for
-       * allocation.
-       */
-      
-      if (used[i] != FALSE)
-       {
-         if (colors[i] == 0)
-           {
-             defs[i].red   = reds[i];
-             defs[i].green = greens[i];
-             defs[i].blue  = blues[i];
-             
-             colors[i] = gdk_color_context_get_pixel (cc, reds[i], greens[i], blues[i], &bad_alloc);
-             
-             /* successfully allocated, store it */
-             
-             if (!bad_alloc)
-               {
-                 defs[i].pixel = colors[i];
-                 allocated[ncols++] = colors[i];
-               }
-             else
-               failed[nopen++] = i;
-           }
-#ifdef DEBUG
-         else
-           GDK_NOTE (COLOR_CONTEXT,
-                     g_message ("gdk_color_context_get_pixels_incremental: "
-                                "pixel at slot %i already allocated, skipping\n", i));
-#endif
-       }
-    }
-  
-  *nallocated = ncols;
-  
-  if ((ncols == ncolors) || (nopen == 0))
-    {
-      GDK_NOTE (COLOR_CONTEXT,
-               g_message ("gdk_color_context_get_pixels_incremental: got all %i colors "
-                          "(%i colors allocated so far)\n",
-                          ncolors, cc->num_allocated));
-      
-      return;
-    }
-  
-  cmapsize = MIN (cc->num_colors, MAX_IMAGE_COLORS);
-  
-  if (cmapsize < 0)
-    {
-      g_warning ("gdk_color_context_get_pixels_incremental: oops!  "
-                "No colors available images will look *really* ugly.");
-      return;
-    }
-  
-#ifdef G_ENABLE_DEBUG
-  exact_col = ncols;
-#endif
-  
-  /* initialize pixels */
-  
-  for (i = 0; i < cmapsize; i++)
-    {
-      cmap[i].pixel = i;
-      cmap[i].red = cmap[i].green = cmap[i].blue = 0;
-    }
-  
-  /* read */
-  
-  my_x_query_colors (cc->colormap, cmap, cmapsize);
-  
-  /* now match any unallocated colors */
-  
-  counter = nopen;
-  nopen = 0;
-  idx = 0;
-  
-  do
-    {
-      gint d, j, mdist, close, ri, gi, bi;
-      gint rd, gd, bd;
-      
-      i = failed[idx];
-      
-      mdist = 0x1000000;
-      close = -1;
-      
-      /* store */
-      
-      ri = reds[i];
-      gi = greens[i];
-      bi = blues[i];
-      
-      for (j = 0; (j < cmapsize) && (mdist != 0); j++)
-       {
-         /* Don't replace these by shifts; the sign may get clobbered */
-         
-         rd = (ri - cmap[j].red) / 256;
-         gd = (gi - cmap[j].green) / 256;
-         bd = (bi - cmap[j].blue) / 256;
-         
-         d = rd * rd + gd * gd + bd * bd;
-         
-         if (d < mdist)
-           {
-             close = j;
-             mdist = d;
-           }
-       }
-      
-      if (close != -1)
-       {
-         rd = cmap[close].red;
-         gd = cmap[close].green;
-         bd = cmap[close].blue;
-         
-         /* allocate */
-         
-         colors[i] = gdk_color_context_get_pixel (cc, rd, gd, bd, &bad_alloc);
-         
-         /* store */
-         
-         if (!bad_alloc)
-           {
-             defs[i] = cmap[close];
-             defs[i].pixel = colors[i];
-             allocated[ncols++] = colors[i];
-#ifdef G_ENABLE_DEBUG
-             close_col++;
-#endif
-           }
-         else
-           failed[nopen++] = i;
-       }
-      else
-       failed[nopen++] = i;
-      /* deal with in next stage if allocation failed */
-    }
-  while (++idx < counter);
-  
-  *nallocated = ncols;
-  
-  if ((ncols == ncolors) || (nopen == 0))
-    {
-      GDK_NOTE (COLOR_CONTEXT,
-               g_message ("gdk_color_context_get_pixels_incremental: "
-                          "got %i colors, %i exact and %i close "
-                          "(%i colors allocated so far)\n",
-                          ncolors, exact_col, close_col, cc->num_allocated));
-      
-      return;
-    }
-  
-  /* map remaining unallocated pixels into colors we did get */
-  
-  idx = 0;
-  
-  do
-    {
-      gint d, mdist, close, ri, gi, bi;
-      gint j, rd, gd, bd;
-      
-      i = failed[idx];
-      
-      mdist = 0x1000000;
-      close = -1;
-      
-      ri = reds[i];
-      gi = greens[i];
-      bi = blues[i];
-      
-      /* search allocated colors */
-      
-      for (j = 0; (j < ncols) && (mdist != 0); j++)
-       {
-         k = allocated[j];
-         
-         /* downscale */
-         /* Don't replace these by shifts; the sign may get clobbered */
-         
-         rd = (ri - defs[k].red) / 256;
-         gd = (gi - defs[k].green) / 256;
-         bd = (bi - defs[k].blue) / 256;
-         
-         d = rd * rd + gd * gd + bd * bd;
-         
-         if (d < mdist)
-           {
-             close = k;
-             mdist = d;
-           }
-       }
-      
-      if (close < 0)
-       {
-         /* too bad, map to black */
-         
-         defs[i].pixel = cc->black_pixel;
-         defs[i].red = defs[i].green = defs[i].blue = 0;
-#ifdef G_ENABLE_DEBUG
-         black_col++;
-#endif
-       }
-      else
-       {
-         defs[i] = defs[close];
-#ifdef G_ENABLE_DEBUG
-         subst_col++;
-#endif
-       }
-      
-      colors[i] = defs[i].pixel;
-    }
-  while (++idx < nopen);
-  
-  GDK_NOTE (COLOR_CONTEXT,
-           g_message ("gdk_color_context_get_pixels_incremental: "
-                      "got %i colors, %i exact, %i close, %i substituted, %i to black "
-                      "(%i colors allocated so far)\n",
-                      ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated));
-}
-
-gint
-gdk_color_context_query_color (GdkColorContext *cc,
-                              GdkColor        *color)
-{
-  return gdk_color_context_query_colors (cc, color, 1);
-}
-
-gint
-gdk_color_context_query_colors (GdkColorContext *cc,
-                               GdkColor        *colors,
-                               gint             num_colors)
-{
-  gint i;
-  GdkColor *tc;
-  
-  g_assert (cc != NULL);
-  g_assert (colors != NULL);
-  
-  switch (cc->mode)
-    {
-    case GDK_CC_MODE_BW:
-      for (i = 0, tc = colors; i < num_colors; i++, tc++)
-       {
-         if (tc->pixel == cc->white_pixel)
-           tc->red = tc->green = tc->blue = 65535;
-         else
-           tc->red = tc->green = tc->blue = 0;
-       }
-      break;
-      
-    case GDK_CC_MODE_TRUE:
-      if (cc->clut == NULL)
-       for (i = 0, tc = colors; i < num_colors; i++, tc++)
-         {
-           tc->red   = ((tc->pixel & cc->masks.red) >> cc->shifts.red) << (16 - cc->bits.red);
-           tc->green = ((tc->pixel & cc->masks.green) >> cc->shifts.green) << (16 - cc->bits.green);
-           tc->blue  = ((tc->pixel & cc->masks.blue) >> cc->shifts.blue) << (16 - cc->bits.blue);
-         }
-      else
-       {
-         my_x_query_colors (cc->colormap, colors, num_colors);
-         return 1;
-       }
-      break;
-      
-    case GDK_CC_MODE_STD_CMAP:
-    default:
-      if (cc->cmap == NULL)
-       {
-         my_x_query_colors (cc->colormap, colors, num_colors);
-         return 1;
-       }
-      else
-       {
-         gint first, last, half;
-         gulong half_pixel;
-         
-         for (i = 0, tc = colors; i < num_colors; i++)
-           {
-             first = 0;
-             last = cc->num_colors - 1;
-             
-             while (first <= last)
-               {
-                 half = (first + last) / 2;
-                 half_pixel = cc->cmap[half].pixel;
-                 
-                 if (tc->pixel == half_pixel)
-                   {
-                     tc->red   = cc->cmap[half].red;
-                     tc->green = cc->cmap[half].green;
-                     tc->blue  = cc->cmap[half].blue;
-                     first = last + 1; /* false break */
-                   }
-                 else
-                   {
-                     if (tc->pixel > half_pixel)
-                       first = half + 1;
-                     else
-                       last = half - 1;
-                   }
-               }
-           }
-         return 1;
-       }
-      break;
-    }
-  return 1;
-}
-
-gint
-gdk_color_context_add_palette (GdkColorContext *cc,
-                              GdkColor        *palette,
-                              gint             num_palette)
-{
-  gint i, j, erg;
-  gushort r, g, b;
-  gulong pixel[1];
-  
-  g_assert (cc != NULL);
-  
-  /* initialize this palette (will also erase previous palette as well) */
-  
-  init_palette (cc);
-  
-  /* restore previous mode if we aren't adding a new palette */
-  
-  if (num_palette == 0)
-    return 0;
-  
-  /* copy incoming palette */
-  
-  cc->palette = g_new0(GdkColor, num_palette);
-  
-  j = 0;
-  
-  for (i = 0; i < num_palette; i++)
-    {
-      erg = 0;
-      pixel[0] = 0;
-      
-      /* try to allocate this color */
-      
-      r = palette[i].red;
-      g = palette[i].green;
-      b = palette[i].blue;
-      
-      gdk_color_context_get_pixels (cc, &r, &g, &b, 1, pixel, &erg);
-      
-      /* only store if we succeed */
-      
-      if (erg)
-       {
-         /* store in palette */
-         
-         cc->palette[j].red   = r;
-         cc->palette[j].green = g;
-         cc->palette[j].blue  = b;
-         cc->palette[j].pixel = pixel[0];
-         
-         /* move to next slot */
-         
-         j++;
-       }
-    }
-  
-  /* resize to fit */
-  
-  if (j != num_palette)
-    cc->palette = g_realloc (cc->palette, j * sizeof (GdkColor));
-  
-  /* clear the hash table, we don't use it when dithering */
-  
-  if (cc->color_hash)
-    {
-      g_hash_table_foreach (cc->color_hash,
-                           free_hash_entry,
-                           NULL);
-      g_hash_table_destroy (cc->color_hash);
-      cc->color_hash = NULL;
-    }
-  
-  /* store real palette size */
-  
-  cc->num_palette = j;
-  
-  /* switch to palette mode */
-  
-  cc->mode = GDK_CC_MODE_PALETTE;
-  
-  /* sort palette */
-  
-  qsort (cc->palette, cc->num_palette, sizeof (GdkColor), pixel_sort);
-  
-  cc->fast_dither = NULL;
-  
-  return j;
-}
-
-void
-gdk_color_context_init_dither (GdkColorContext *cc)
-{
-  gint rr, gg, bb, err, erg, erb;
-  gint success = FALSE;
-  
-  g_assert (cc != NULL);
-  
-  /* now we can initialize the fast dither matrix */
-  
-  if (cc->fast_dither == NULL)
-    cc->fast_dither = g_new (GdkColorContextDither, 1);
-  
-  /* Fill it.  We ignore unsuccessful allocations, they are just mapped
-   * to black instead */
-  
-  for (rr = 0; rr < 32; rr++)
-    for (gg = 0; gg < 32; gg++)
-      for (bb = 0; bb < 32; bb++)
-       {
-         err = (rr << 3) | (rr >> 2);
-         erg = (gg << 3) | (gg >> 2);
-         erb = (bb << 3) | (bb >> 2);
-         
-         cc->fast_dither->fast_rgb[rr][gg][bb] =
-           gdk_color_context_get_index_from_palette (cc, &err, &erg, &erb, &success);
-         cc->fast_dither->fast_err[rr][gg][bb] = err;
-         cc->fast_dither->fast_erg[rr][gg][bb] = erg;
-         cc->fast_dither->fast_erb[rr][gg][bb] = erb;
-       }
-}
-
-void
-gdk_color_context_free_dither (GdkColorContext *cc)
-{
-  g_assert (cc != NULL);
-  
-  if (cc->fast_dither)
-    g_free (cc->fast_dither);
-  
-  cc->fast_dither = NULL;
-}
-
-gulong
-gdk_color_context_get_pixel_from_palette (GdkColorContext *cc,
-                                         gushort         *red,
-                                         gushort         *green,
-                                         gushort         *blue,
-                                         gint            *failed)
-{
-  gulong pixel = 0;
-  gint dif, dr, dg, db, j = -1;
-  gint mindif = 0x7fffffff;
-  gint err = 0, erg = 0, erb = 0;
-  gint i;
-  
-  g_assert (cc != NULL);
-  g_assert (red != NULL);
-  g_assert (green != NULL);
-  g_assert (blue != NULL);
-  g_assert (failed != NULL);
-  
-  *failed = FALSE;
-  
-  for (i = 0; i < cc->num_palette; i++)
-    {
-      dr = *red - cc->palette[i].red;
-      dg = *green - cc->palette[i].green;
-      db = *blue - cc->palette[i].blue;
-      
-      dif = dr * dr + dg * dg + db * db;
-      
-      if (dif < mindif)
-       {
-         mindif = dif;
-         j = i;
-         pixel = cc->palette[i].pixel;
-         err = dr;
-         erg = dg;
-         erb = db;
-         
-         if (mindif == 0)
-           break;
-       }
-    }
-  
-  /* we failed to map onto a color */
-  
-  if (j == -1)
-    *failed = TRUE;
-  else
-    {
-      *red   = ABS (err);
-      *green = ABS (erg);
-      *blue  = ABS (erb);
-    }
-  
-  return pixel;
-}
-
-guchar
-gdk_color_context_get_index_from_palette (GdkColorContext *cc,
-                                         gint            *red,
-                                         gint            *green,
-                                         gint            *blue,
-                                         gint            *failed)
-{
-  gint dif, dr, dg, db, j = -1;
-  gint mindif = 0x7fffffff;
-  gint err = 0, erg = 0, erb = 0;
-  gint i;
-  
-  g_assert (cc != NULL);
-  g_assert (red != NULL);
-  g_assert (green != NULL);
-  g_assert (blue != NULL);
-  g_assert (failed != NULL);
-  
-  *failed = FALSE;
-  
-  for (i = 0; i < cc->num_palette; i++)
-    {
-      dr = *red - cc->palette[i].red;
-      dg = *green - cc->palette[i].green;
-      db = *blue - cc->palette[i].blue;
-      
-      dif = dr * dr + dg * dg + db * db;
-      
-      if (dif < mindif)
-       {
-         mindif = dif;
-         j = i;
-         err = dr;
-         erg = dg;
-         erb = db;
-         
-         if (mindif == 0)
-           break;
-       }
-    }
-  
-  /* we failed to map onto a color */
-  
-  if (j == -1)
-    {
-      *failed = TRUE;
-      j = 0;
-    }
-  else
-    {
-      /* return error fractions */
-      
-      *red   = err;
-      *green = erg;
-      *blue  = erb;
-    }
-  
-  return j;
-}
index 03222cc3d6199d8520cbf57ff5a82b1421a9e555..47a35af48c5b1840b53c8e2797d97bb52d88797f 100644 (file)
  */
 
 #include <time.h>
-#include <X11/Xlib.h>
 
 #include "gdkcolor.h"
 #include "gdkprivate.h"
 
-
-static gint  gdk_colormap_match_color (GdkColormap *cmap,
-                                      GdkColor    *color,
-                                      const gchar *available);
-static void  gdk_colormap_add         (GdkColormap *cmap);
-static void  gdk_colormap_remove      (GdkColormap *cmap);
-static guint gdk_colormap_hash        (Colormap    *cmap);
-static gint  gdk_colormap_cmp         (Colormap    *a,
-                                      Colormap    *b);
-static void gdk_colormap_real_destroy (GdkColormap *colormap);
-
-static GHashTable *colormap_hash = NULL;
-
-
-GdkColormap*
-gdk_colormap_new (GdkVisual *visual,
-                 gint       private_cmap)
-{
-  GdkColormap *colormap;
-  GdkColormapPrivate *private;
-  Visual *xvisual;
-  int size;
-  int i;
-
-  g_return_val_if_fail (visual != NULL, NULL);
-
-  private = g_new (GdkColormapPrivate, 1);
-  colormap = (GdkColormap*) private;
-
-  private->xdisplay = gdk_display;
-  private->visual = visual;
-  private->ref_count = 1;
-
-  private->hash = NULL;
-  private->last_sync_time = 0;
-  private->info = NULL;
-  
-  xvisual = ((GdkVisualPrivate*) visual)->xvisual;
-
-  colormap->size = visual->colormap_size;
-  colormap->colors = NULL;
-
-  switch (visual->type)
-    {
-    case GDK_VISUAL_GRAYSCALE:
-    case GDK_VISUAL_PSEUDO_COLOR:
-      private->info = g_new0 (GdkColorInfo, colormap->size);
-      colormap->colors = g_new (GdkColor, colormap->size);
-      
-      private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
-                                       (GCompareFunc) gdk_color_equal);
-      
-      private->private_val = private_cmap;
-      private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
-                                           xvisual, (private_cmap) ? (AllocAll) : (AllocNone));
-
-      if (private_cmap)
-       {
-         XColor *default_colors;
-
-         default_colors = g_new (XColor, colormap->size);
-
-         for (i = 0; i < colormap->size; i++)
-           default_colors[i].pixel = i;
-
-         XQueryColors (private->xdisplay,
-                       DefaultColormap (private->xdisplay, gdk_screen),
-                       default_colors, colormap->size);
-
-         for (i = 0; i < colormap->size; i++)
-           {
-             colormap->colors[i].pixel = default_colors[i].pixel;
-             colormap->colors[i].red = default_colors[i].red;
-             colormap->colors[i].green = default_colors[i].green;
-             colormap->colors[i].blue = default_colors[i].blue;
-           }
-
-         gdk_colormap_change (colormap, colormap->size);
-         
-         g_free (default_colors);
-       }
-      break;
-
-    case GDK_VISUAL_DIRECT_COLOR:
-      private->private_val = TRUE;
-      private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
-                                           xvisual, AllocAll);
-      colormap->colors = g_new (GdkColor, colormap->size);
-
-      size = 1 << visual->red_prec;
-      for (i = 0; i < size; i++)
-       colormap->colors[i].red = i * 65535 / (size - 1);
-
-      size = 1 << visual->green_prec;
-      for (i = 0; i < size; i++)
-       colormap->colors[i].green = i * 65535 / (size - 1);
-
-      size = 1 << visual->blue_prec;
-      for (i = 0; i < size; i++)
-       colormap->colors[i].blue = i * 65535 / (size - 1);
-
-      gdk_colormap_change (colormap, colormap->size);
-      break;
-
-    case GDK_VISUAL_STATIC_GRAY:
-    case GDK_VISUAL_STATIC_COLOR:
-    case GDK_VISUAL_TRUE_COLOR:
-      private->private_val = FALSE;
-      private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
-                                           xvisual, AllocNone);
-      break;
-    }
-
-  gdk_colormap_add (colormap);
-
-  return colormap;
-}
-
-static void
-gdk_colormap_real_destroy (GdkColormap *colormap)
-{
-  GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
-
-  g_return_if_fail (colormap != NULL);
-  g_return_if_fail (private->ref_count == 0);
-
-  gdk_colormap_remove (colormap);
-  XFreeColormap (private->xdisplay, private->xcolormap);
-
-  if (private->hash)
-    g_hash_table_destroy (private->hash);
-  
-  g_free (private->info);
-  g_free (colormap->colors);
-  g_free (colormap);
-}
-
 GdkColormap*
 gdk_colormap_ref (GdkColormap *cmap)
 {
@@ -188,7 +50,7 @@ gdk_colormap_unref (GdkColormap *cmap)
 
   private->ref_count -= 1;
   if (private->ref_count == 0)
-    gdk_colormap_real_destroy (cmap);
+    _gdk_colormap_real_destroy (cmap);
 }
 
 GdkVisual *
@@ -203,187 +65,6 @@ gdk_colormap_get_visual (GdkColormap *colormap)
   return private->visual;
 }
      
-#define MIN_SYNC_TIME 2
-
-void
-gdk_colormap_sync (GdkColormap *colormap,
-                  gboolean     force)
-{
-  time_t current_time;
-  GdkColormapPrivate *private = (GdkColormapPrivate *)colormap;
-  XColor *xpalette;
-  gint nlookup;
-  gint i;
-  
-  g_return_if_fail (colormap != NULL);
-
-  current_time = time (NULL);
-  if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
-    return;
-
-  private->last_sync_time = current_time;
-
-  nlookup = 0;
-  xpalette = g_new (XColor, colormap->size);
-  
-  for (i = 0; i < colormap->size; i++)
-    {
-      if (private->info[i].ref_count == 0)
-       {
-         xpalette[nlookup].pixel = i;
-         xpalette[nlookup].red = 0;
-         xpalette[nlookup].green = 0;
-         xpalette[nlookup].blue = 0;
-         nlookup++;
-       }
-    }
-  
-  XQueryColors (gdk_display, private->xcolormap, xpalette, nlookup);
-  
-  for (i = 0; i < nlookup; i++)
-    {
-      gulong pixel = xpalette[i].pixel;
-      colormap->colors[pixel].pixel = pixel;
-      colormap->colors[pixel].red = xpalette[i].red;
-      colormap->colors[pixel].green = xpalette[i].green;
-      colormap->colors[pixel].blue = xpalette[i].blue;
-    }
-  
-  g_free (xpalette);
-}
-                  
-
-GdkColormap*
-gdk_colormap_get_system (void)
-{
-  static GdkColormap *colormap = NULL;
-  GdkColormapPrivate *private;
-
-  if (!colormap)
-    {
-      private = g_new (GdkColormapPrivate, 1);
-      colormap = (GdkColormap*) private;
-
-      private->xdisplay = gdk_display;
-      private->xcolormap = DefaultColormap (gdk_display, gdk_screen);
-      private->visual = gdk_visual_get_system ();
-      private->private_val = FALSE;
-      private->ref_count = 1;
-
-      private->hash = NULL;
-      private->last_sync_time = 0;
-      private->info = NULL;
-
-      colormap->colors = NULL;
-      colormap->size = private->visual->colormap_size;
-
-      if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
-         (private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
-       {
-         private->info = g_new0 (GdkColorInfo, colormap->size);
-         colormap->colors = g_new (GdkColor, colormap->size);
-         
-         private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
-                                           (GCompareFunc) gdk_color_equal);
-
-         gdk_colormap_sync (colormap, TRUE);
-       }
-
-      gdk_colormap_add (colormap);
-    }
-
-  return colormap;
-}
-
-gint
-gdk_colormap_get_system_size (void)
-{
-  return DisplayCells (gdk_display, gdk_screen);
-}
-
-void
-gdk_colormap_change (GdkColormap *colormap,
-                    gint         ncolors)
-{
-  GdkColormapPrivate *private;
-  GdkVisual *visual;
-  XColor *palette;
-  gint shift;
-  int max_colors;
-  int size;
-  int i;
-
-  g_return_if_fail (colormap != NULL);
-
-  palette = g_new (XColor, ncolors);
-
-  private = (GdkColormapPrivate*) colormap;
-  switch (private->visual->type)
-    {
-    case GDK_VISUAL_GRAYSCALE:
-    case GDK_VISUAL_PSEUDO_COLOR:
-      for (i = 0; i < ncolors; i++)
-       {
-         palette[i].pixel = colormap->colors[i].pixel;
-         palette[i].red = colormap->colors[i].red;
-         palette[i].green = colormap->colors[i].green;
-         palette[i].blue = colormap->colors[i].blue;
-         palette[i].flags = DoRed | DoGreen | DoBlue;
-       }
-
-      XStoreColors (private->xdisplay, private->xcolormap, palette, ncolors);
-      break;
-
-    case GDK_VISUAL_DIRECT_COLOR:
-      visual = private->visual;
-
-      shift = visual->red_shift;
-      max_colors = 1 << visual->red_prec;
-      size = (ncolors < max_colors) ? (ncolors) : (max_colors);
-
-      for (i = 0; i < size; i++)
-       {
-         palette[i].pixel = i << shift;
-         palette[i].red = colormap->colors[i].red;
-         palette[i].flags = DoRed;
-       }
-
-      XStoreColors (private->xdisplay, private->xcolormap, palette, size);
-
-      shift = visual->green_shift;
-      max_colors = 1 << visual->green_prec;
-      size = (ncolors < max_colors) ? (ncolors) : (max_colors);
-
-      for (i = 0; i < size; i++)
-       {
-         palette[i].pixel = i << shift;
-         palette[i].green = colormap->colors[i].green;
-         palette[i].flags = DoGreen;
-       }
-
-      XStoreColors (private->xdisplay, private->xcolormap, palette, size);
-
-      shift = visual->blue_shift;
-      max_colors = 1 << visual->blue_prec;
-      size = (ncolors < max_colors) ? (ncolors) : (max_colors);
-
-      for (i = 0; i < size; i++)
-       {
-         palette[i].pixel = i << shift;
-         palette[i].blue = colormap->colors[i].blue;
-         palette[i].flags = DoBlue;
-       }
-
-      XStoreColors (private->xdisplay, private->xcolormap, palette, size);
-      break;
-
-    default:
-      break;
-    }
-
-  g_free (palette);
-}
-
 void
 gdk_colors_store (GdkColormap   *colormap,
                  GdkColor      *colors,
@@ -402,37 +83,6 @@ gdk_colors_store (GdkColormap   *colormap,
   gdk_colormap_change (colormap, ncolors);
 }
 
-gboolean
-gdk_colors_alloc (GdkColormap   *colormap,
-                 gint           contiguous,
-                 gulong        *planes,
-                 gint           nplanes,
-                 gulong        *pixels,
-                 gint           npixels)
-{
-  GdkColormapPrivate *private;
-  gint return_val;
-  gint i;
-
-  g_return_val_if_fail (colormap != NULL, 0);
-
-  private = (GdkColormapPrivate*) colormap;
-
-  return_val = XAllocColorCells (private->xdisplay, private->xcolormap,
-                                contiguous, planes, nplanes, pixels, npixels);
-
-  if (return_val)
-    {
-      for (i=0; i<npixels; i++)
-       {
-         private->info[pixels[i]].ref_count++;
-         private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
-       }
-    }
-
-  return return_val != 0;
-}
-
 /*
  *--------------------------------------------------------------
  * gdk_color_copy
@@ -499,7 +149,6 @@ gdk_color_white (GdkColormap *colormap,
 
   if (color)
     {
-      color->pixel = WhitePixel (gdk_display, gdk_screen);
       color->red = 65535;
       color->green = 65535;
       color->blue = 65535;
@@ -522,7 +171,6 @@ gdk_color_black (GdkColormap *colormap,
 
   if (color)
     {
-      color->pixel = BlackPixel (gdk_display, gdk_screen);
       color->red = 0;
       color->green = 0;
       color->blue = 0;
@@ -535,534 +183,10 @@ gdk_color_black (GdkColormap *colormap,
   return return_val;
 }
 
-gboolean
-gdk_color_parse (const gchar *spec,
-                GdkColor *color)
-{
-  Colormap xcolormap;
-  XColor xcolor;
-  gboolean return_val;
-
-  g_return_val_if_fail (spec != NULL, FALSE);
-  g_return_val_if_fail (color != NULL, FALSE);
-
-  xcolormap = DefaultColormap (gdk_display, gdk_screen);
-
-  if (XParseColor (gdk_display, xcolormap, spec, &xcolor))
-    {
-      return_val = TRUE;
-      color->red = xcolor.red;
-      color->green = xcolor.green;
-      color->blue = xcolor.blue;
-    }
-  else
-    return_val = FALSE;
-
-  return return_val;
-}
-
-/* This is almost identical to gdk_colormap_free_colors.
- * Keep them in sync!
- */
-void
-gdk_colors_free (GdkColormap *colormap,
-                gulong      *in_pixels,
-                gint         in_npixels,
-                gulong       planes)
-{
-  GdkColormapPrivate *private;
-  gulong *pixels;
-  gint npixels = 0;
-  gint i;
-
-  g_return_if_fail (colormap != NULL);
-  g_return_if_fail (in_pixels != NULL);
-
-  private = (GdkColormapPrivate*) colormap;
-
-  if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
-      (private->visual->type != GDK_VISUAL_GRAYSCALE))
-    return;
-  
-  pixels = g_new (gulong, in_npixels);
-
-  for (i=0; i<in_npixels; i++)
-    {
-      gulong pixel = in_pixels[i];
-      
-      if (private->info[pixel].ref_count)
-       {
-         private->info[pixel].ref_count--;
-
-         if (private->info[pixel].ref_count == 0)
-           {
-             pixels[npixels++] = pixel;
-             if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
-               g_hash_table_remove (private->hash, &colormap->colors[pixel]);
-             private->info[pixel].flags = 0;
-           }
-       }
-    }
-
-  if (npixels)
-    XFreeColors (private->xdisplay, private->xcolormap,
-                pixels, npixels, planes);
-  g_free (pixels);
-}
-
-/* This is almost identical to gdk_colors_free.
- * Keep them in sync!
- */
-void
-gdk_colormap_free_colors (GdkColormap *colormap,
-                         GdkColor    *colors,
-                         gint         ncolors)
-{
-  GdkColormapPrivate *private;
-  gulong *pixels;
-  gint npixels = 0;
-  gint i;
-
-  g_return_if_fail (colormap != NULL);
-  g_return_if_fail (colors != NULL);
-
-  private = (GdkColormapPrivate*) colormap;
-
-  if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
-      (private->visual->type != GDK_VISUAL_GRAYSCALE))
-    return;
-
-  pixels = g_new (gulong, ncolors);
-
-  for (i=0; i<ncolors; i++)
-    {
-      gulong pixel = colors[i].pixel;
-      
-      if (private->info[pixel].ref_count)
-       {
-         private->info[pixel].ref_count--;
-
-         if (private->info[pixel].ref_count == 0)
-           {
-             pixels[npixels++] = pixel;
-             if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
-               g_hash_table_remove (private->hash, &colormap->colors[pixel]);
-             private->info[pixel].flags = 0;
-           }
-       }
-    }
-
-  if (npixels)
-    XFreeColors (private->xdisplay, private->xcolormap,
-                pixels, npixels, 0);
-
-  g_free (pixels);
-}
-
 /********************
  * Color allocation *
  ********************/
 
-/* Try to allocate a single color using XAllocColor. If it succeeds,
- * cache the result in our colormap, and store in ret.
- */
-static gboolean 
-gdk_colormap_alloc1 (GdkColormap *colormap,
-                    GdkColor    *color,
-                    GdkColor    *ret)
-{
-  GdkColormapPrivate *private;
-  XColor xcolor;
-
-  private = (GdkColormapPrivate*) colormap;
-
-  xcolor.red = color->red;
-  xcolor.green = color->green;
-  xcolor.blue = color->blue;
-  xcolor.pixel = color->pixel;
-  xcolor.flags = DoRed | DoGreen | DoBlue;
-
-  if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
-    {
-      ret->pixel = xcolor.pixel;
-      ret->red = xcolor.red;
-      ret->green = xcolor.green;
-      ret->blue = xcolor.blue;
-      
-      if (ret->pixel < colormap->size)
-       {
-         if (private->info[ret->pixel].ref_count) /* got a duplicate */
-           {
-             XFreeColors (private->xdisplay, private->xcolormap,
-                          &ret->pixel, 1, 0);
-           }
-         else
-           {
-             colormap->colors[ret->pixel] = *color;
-             colormap->colors[ret->pixel].pixel = ret->pixel;
-             private->info[ret->pixel].ref_count = 1;
-
-             g_hash_table_insert (private->hash,
-                                  &colormap->colors[ret->pixel],
-                                  &colormap->colors[ret->pixel]);
-           }
-       }
-      return TRUE;
-    }
-  else
-    {
-      return FALSE;
-    }
-}
-
-static gint
-gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
-                                    GdkColor    *colors,
-                                    gint         ncolors,
-                                    gboolean     writeable,
-                                    gboolean     best_match,
-                                    gboolean    *success)
-{
-  GdkColormapPrivate *private;
-  gulong *pixels;
-  Status status;
-  gint i, index;
-
-  private = (GdkColormapPrivate*) colormap;
-
-  if (private->private_val)
-    {
-      index = 0;
-      for (i=0; i<ncolors; i++)
-       {
-         while ((index < colormap->size) && (private->info[index].ref_count != 0))
-           index++;
-         
-         if (index < colormap->size)
-           {
-             colors[i].pixel = index;
-             success[i] = TRUE;
-             private->info[index].ref_count++;
-             private->info[i].flags |= GDK_COLOR_WRITEABLE;
-           }
-         else
-           break;
-       }
-      return i;
-    }
-  else
-    {
-      pixels = g_new (gulong, ncolors);
-      /* Allocation of a writeable color cells */
-      
-      status =  XAllocColorCells (private->xdisplay, private->xcolormap,
-                                 FALSE, NULL, 0, pixels, ncolors);
-      if (status)
-       {
-         for (i=0; i<ncolors; i++)
-           {
-             colors[i].pixel = pixels[i];
-             private->info[pixels[i]].ref_count++;
-             private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
-           }
-       }
-      
-      g_free (pixels);
-
-      return status ? ncolors : 0; 
-    }
-}
-
-static gint
-gdk_colormap_alloc_colors_private (GdkColormap *colormap,
-                                  GdkColor    *colors,
-                                  gint         ncolors,
-                                  gboolean     writeable,
-                                  gboolean     best_match,
-                                  gboolean    *success)
-{
-  GdkColormapPrivate *private;
-  gint i, index;
-  XColor *store = g_new (XColor, ncolors);
-  gint nstore = 0;
-  gint nremaining = 0;
-  
-  private = (GdkColormapPrivate*) colormap;
-  index = -1;
-
-  /* First, store the colors we have room for */
-
-  index = 0;
-  for (i=0; i<ncolors; i++)
-    {
-      if (!success[i])
-       {
-         while ((index < colormap->size) && (private->info[index].ref_count != 0))
-           index++;
-
-         if (index < colormap->size)
-           {
-             store[nstore].red = colors[i].red;
-             store[nstore].blue = colors[i].blue;
-             store[nstore].green = colors[i].green;
-             store[nstore].pixel = index;
-             nstore++;
-
-             success[i] = TRUE;
-
-             colors[i].pixel = index;
-             private->info[index].ref_count++;
-           }
-         else
-           nremaining++;
-       }
-    }
-  
-  XStoreColors (private->xdisplay, private->xcolormap, store, nstore);
-  g_free (store);
-
-  if (nremaining > 0 && best_match)
-    {
-      /* Get best matches for remaining colors */
-
-      gchar *available = g_new (gchar, colormap->size);
-      for (i = 0; i < colormap->size; i++)
-       available[i] = TRUE;
-
-      for (i=0; i<ncolors; i++)
-       {
-         if (!success[i])
-           {
-             index = gdk_colormap_match_color (colormap, 
-                                               &colors[i], 
-                                               available);
-             if (index != -1)
-               {
-                 colors[i] = colormap->colors[index];
-                 private->info[index].ref_count++;
-
-                 success[i] = TRUE;
-                 nremaining--;
-               }
-           }
-       }
-      g_free (available);
-    }
-
-  return (ncolors - nremaining);
-}
-
-static gint
-gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
-                                 GdkColor    *colors,
-                                 gint         ncolors,
-                                 gboolean     writeable,
-                                 gboolean     best_match,
-                                 gboolean    *success)
-{
-  GdkColormapPrivate *private;
-  gint i, index;
-  gint nremaining = 0;
-  gint nfailed = 0;
-
-  private = (GdkColormapPrivate*) colormap;
-  index = -1;
-
-  for (i=0; i<ncolors; i++)
-    {
-      if (!success[i])
-       {
-         if (gdk_colormap_alloc1 (colormap, &colors[i], &colors[i]))
-           success[i] = TRUE;
-         else
-           nremaining++;
-       }
-    }
-
-
-  if (nremaining > 0 && best_match)
-    {
-      gchar *available = g_new (gchar, colormap->size);
-      for (i = 0; i < colormap->size; i++)
-       available[i] = ((private->info[i].ref_count == 0) ||
-                       !(private->info[i].flags && GDK_COLOR_WRITEABLE));
-      gdk_colormap_sync (colormap, FALSE);
-      
-      while (nremaining > 0)
-       {
-         for (i=0; i<ncolors; i++)
-           {
-             if (!success[i])
-               {
-                 index = gdk_colormap_match_color (colormap, &colors[i], available);
-                 if (index != -1)
-                   {
-                     if (private->info[index].ref_count)
-                       {
-                         private->info[index].ref_count++;
-                         colors[i] = colormap->colors[index];
-                         success[i] = TRUE;
-                         nremaining--;
-                       }
-                     else
-                       {
-                         if (gdk_colormap_alloc1 (colormap, 
-                                                  &colormap->colors[index],
-                                                  &colors[i]))
-                           {
-                             success[i] = TRUE;
-                             nremaining--;
-                             break;
-                           }
-                         else
-                           {
-                             available[index] = FALSE;
-                           }
-                       }
-                   }
-                 else
-                   {
-                     nfailed++;
-                     nremaining--;
-                     success[i] = 2; /* flag as permanent failure */
-                   }
-               }
-           }
-       }
-      g_free (available);
-    }
-
-  /* Change back the values we flagged as permanent failures */
-  if (nfailed > 0)
-    {
-      for (i=0; i<ncolors; i++)
-       if (success[i] == 2)
-         success[i] = FALSE;
-      nremaining = nfailed;
-    }
-  
-  return (ncolors - nremaining);
-}
-
-static gint
-gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
-                                      GdkColor    *colors,
-                                      gint         ncolors,
-                                      gboolean     writeable,
-                                      gboolean     best_match,
-                                      gboolean    *success)
-{
-  GdkColormapPrivate *private;
-  GdkColor *lookup_color;
-  gint i;
-  gint nremaining = 0;
-
-  private = (GdkColormapPrivate*) colormap;
-
-  /* Check for an exact match among previously allocated colors */
-
-  for (i=0; i<ncolors; i++)
-    {
-      if (!success[i])
-       {
-         lookup_color = g_hash_table_lookup (private->hash, &colors[i]);
-         if (lookup_color)
-           {
-             private->info[lookup_color->pixel].ref_count++;
-             colors[i].pixel = lookup_color->pixel;
-             success[i] = TRUE;
-           }
-         else
-           nremaining++;
-       }
-    }
-
-  /* If that failed, we try to allocate a new color, or approxmiate
-   * with what we can get if best_match is TRUE.
-   */
-  if (nremaining > 0)
-    {
-      if (private->private_val)
-       return gdk_colormap_alloc_colors_private (colormap, colors, ncolors, writeable, best_match, success);
-      else
-       return gdk_colormap_alloc_colors_shared (colormap, colors, ncolors, writeable, best_match, success);
-    }
-  else
-    return 0;
-}
-
-gint
-gdk_colormap_alloc_colors (GdkColormap *colormap,
-                          GdkColor    *colors,
-                          gint         ncolors,
-                          gboolean     writeable,
-                          gboolean     best_match,
-                          gboolean    *success)
-{
-  GdkColormapPrivate *private;
-  GdkVisual *visual;
-  gint i;
-  gint nremaining = 0;
-  XColor xcolor;
-
-  g_return_val_if_fail (colormap != NULL, FALSE);
-  g_return_val_if_fail (colors != NULL, FALSE);
-
-  private = (GdkColormapPrivate*) colormap;
-
-  for (i=0; i<ncolors; i++)
-    {
-      success[i] = FALSE;
-    }
-
-  switch (private->visual->type)
-    {
-    case GDK_VISUAL_PSEUDO_COLOR:
-    case GDK_VISUAL_GRAYSCALE:
-      if (writeable)
-       return gdk_colormap_alloc_colors_writeable (colormap, colors, ncolors,
-                                                   writeable, best_match, success);
-      else
-       return gdk_colormap_alloc_colors_pseudocolor (colormap, colors, ncolors,
-                                                   writeable, best_match, success);
-      break;
-
-    case GDK_VISUAL_DIRECT_COLOR:
-    case GDK_VISUAL_TRUE_COLOR:
-      visual = private->visual;
-
-      for (i=0; i<ncolors; i++)
-       {
-         colors[i].pixel = (((colors[i].red >> (16 - visual->red_prec)) << visual->red_shift) +
-                            ((colors[i].green >> (16 - visual->green_prec)) << visual->green_shift) +
-                            ((colors[i].blue >> (16 - visual->blue_prec)) << visual->blue_shift));
-         success[i] = TRUE;
-       }
-      break;
-
-    case GDK_VISUAL_STATIC_GRAY:
-    case GDK_VISUAL_STATIC_COLOR:
-      for (i=0; i<ncolors; i++)
-       {
-         xcolor.red = colors[i].red;
-         xcolor.green = colors[i].green;
-         xcolor.blue = colors[i].blue;
-         xcolor.pixel = colors[i].pixel;
-         xcolor.flags = DoRed | DoGreen | DoBlue;
-
-         if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
-           {
-             colors[i].pixel = xcolor.pixel;
-             success[i] = TRUE;
-           }
-         else
-           nremaining++;
-       }
-      break;
-    }
-  return nremaining;
-}
-
 gboolean
 gdk_colormap_alloc_color (GdkColormap *colormap,
                          GdkColor    *color,
@@ -1088,28 +212,6 @@ gdk_color_alloc (GdkColormap *colormap,
   return success;
 }
 
-gboolean
-gdk_color_change (GdkColormap *colormap,
-                 GdkColor    *color)
-{
-  GdkColormapPrivate *private;
-  XColor xcolor;
-
-  g_return_val_if_fail (colormap != NULL, FALSE);
-  g_return_val_if_fail (color != NULL, FALSE);
-
-  xcolor.pixel = color->pixel;
-  xcolor.red = color->red;
-  xcolor.green = color->green;
-  xcolor.blue = color->blue;
-  xcolor.flags = DoRed | DoGreen | DoBlue;
-
-  private = (GdkColormapPrivate*) colormap;
-  XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
-
-  return TRUE;
-}
-
 guint
 gdk_color_hash (const GdkColor *colora)
 {
@@ -1130,153 +232,3 @@ gdk_color_equal (const GdkColor *colora,
          (colora->green == colorb->green) &&
          (colora->blue == colorb->blue));
 }
-
-/* XXX: Do not use this function until it is fixed. An X Colormap
- *      is useless unless we also have the visual.
- */
-GdkColormap*
-gdkx_colormap_get (Colormap xcolormap)
-{
-  GdkColormap *colormap;
-  GdkColormapPrivate *private;
-
-  colormap = gdk_colormap_lookup (xcolormap);
-  if (colormap)
-    return colormap;
-
-  if (xcolormap == DefaultColormap (gdk_display, gdk_screen))
-    return gdk_colormap_get_system ();
-
-  private = g_new (GdkColormapPrivate, 1);
-  colormap = (GdkColormap*) private;
-
-  private->xdisplay = gdk_display;
-  private->xcolormap = xcolormap;
-  private->visual = NULL;
-  private->private_val = TRUE;
-
-  /* To do the following safely, we would have to have some way of finding
-   * out what the size or visual of the given colormap is. It seems
-   * X doesn't allow this
-   */
-
-#if 0
-  for (i = 0; i < 256; i++)
-    {
-      xpalette[i].pixel = i;
-      xpalette[i].red = 0;
-      xpalette[i].green = 0;
-      xpalette[i].blue = 0;
-    }
-
-  XQueryColors (gdk_display, private->xcolormap, xpalette, 256);
-
-  for (i = 0; i < 256; i++)
-    {
-      colormap->colors[i].pixel = xpalette[i].pixel;
-      colormap->colors[i].red = xpalette[i].red;
-      colormap->colors[i].green = xpalette[i].green;
-      colormap->colors[i].blue = xpalette[i].blue;
-    }
-#endif
-
-  colormap->colors = NULL;
-  colormap->size = 0;
-
-  gdk_colormap_add (colormap);
-
-  return colormap;
-}
-
-
-static gint
-gdk_colormap_match_color (GdkColormap *cmap,
-                         GdkColor    *color,
-                         const gchar *available)
-{
-  GdkColor *colors;
-  guint sum, max;
-  gint rdiff, gdiff, bdiff;
-  gint i, index;
-
-  g_return_val_if_fail (cmap != NULL, 0);
-  g_return_val_if_fail (color != NULL, 0);
-
-  colors = cmap->colors;
-  max = 3 * (65536);
-  index = -1;
-
-  for (i = 0; i < cmap->size; i++)
-    {
-      if ((!available) || (available && available[i]))
-       {
-         rdiff = (color->red - colors[i].red);
-         gdiff = (color->green - colors[i].green);
-         bdiff = (color->blue - colors[i].blue);
-
-         sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
-
-         if (sum < max)
-           {
-             index = i;
-             max = sum;
-           }
-       }
-    }
-
-  return index;
-}
-
-
-GdkColormap*
-gdk_colormap_lookup (Colormap xcolormap)
-{
-  GdkColormap *cmap;
-
-  if (!colormap_hash)
-    return NULL;
-
-  cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
-  return cmap;
-}
-
-static void
-gdk_colormap_add (GdkColormap *cmap)
-{
-  GdkColormapPrivate *private;
-
-  if (!colormap_hash)
-    colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
-                                     (GCompareFunc) gdk_colormap_cmp);
-
-  private = (GdkColormapPrivate*) cmap;
-
-  g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
-}
-
-static void
-gdk_colormap_remove (GdkColormap *cmap)
-{
-  GdkColormapPrivate *private;
-
-  if (!colormap_hash)
-    colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
-                                     (GCompareFunc) gdk_colormap_cmp);
-
-  private = (GdkColormapPrivate*) cmap;
-
-  g_hash_table_remove (colormap_hash, &private->xcolormap);
-}
-
-static guint
-gdk_colormap_hash (Colormap *cmap)
-{
-  return *cmap;
-}
-
-static gint
-gdk_colormap_cmp (Colormap *a,
-                 Colormap *b)
-{
-  return (*a == *b);
-}
index 04da2147cc03372cf938abf12f16f8ecae0d0d79..d82d8f69d93696d6164db0ea33b60824510b2450 100644 (file)
@@ -13,15 +13,28 @@ extern "C" {
 
 #define GdkWindowType                  GdkDrawableType
 
+#define gdk_draw_pixmap                gdk_draw_drawable
+#define gdk_draw_bitmap                gdk_draw_drawable
+
 #define gdk_window_get_size            gdk_drawable_get_size
 #define gdk_window_get_type            gdk_drawable_get_type
 #define gdk_window_get_colormap        gdk_drawable_get_colormap
 #define gdk_window_set_colormap        gdk_drawable_set_colormap
 #define gdk_window_get_visual          gdk_drawable_get_visual
 
+#define gdk_window_ref                 gdk_drawable_ref
+#define gdk_window_unref               gdk_drawable_unref
+#define gdk_bitmap_ref                 gdk_drawable_ref
+#define gdk_bitmap_unref               gdk_drawable_unref
+#define gdk_pixmap_ref                 gdk_drawable_ref
+#define gdk_pixmap_unref               gdk_drawable_unref
+
 #define gdk_window_copy_area(drawable,gc,x,y,source_drawable,source_x,source_y,width,height) \
    gdk_draw_pixmap(drawable,gc,source_drawable,source_x,source_y,x,y,width,height)
 
+#define gdk_gc_destroy                 gdk_gc_unref
+#define gdk_image_destroy              gdk_image_unref
+
 #define GDK_WINDOW_PIXMAP GDK_DRAWABLE_PIXMAP
              
 #endif /* GDK_DISABLE_COMPAT_H */
diff --git a/gdk/gdkcursor.c b/gdk/gdkcursor.c
deleted file mode 100644 (file)
index 04260a2..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <X11/Xlib.h>
-#include <X11/cursorfont.h>
-
-#include "gdkx.h"
-#include "gdkcursor.h"
-#include "gdkprivate.h"
-
-
-GdkCursor*
-gdk_cursor_new (GdkCursorType cursor_type)
-{
-  GdkCursorPrivate *private;
-  GdkCursor *cursor;
-  Cursor xcursor;
-
-  xcursor = XCreateFontCursor (gdk_display, cursor_type);
-  private = g_new (GdkCursorPrivate, 1);
-  private->xdisplay = gdk_display;
-  private->xcursor = xcursor;
-  cursor = (GdkCursor*) private;
-  cursor->type = cursor_type;
-
-  return cursor;
-}
-
-GdkCursor*
-gdk_cursor_new_from_pixmap (GdkPixmap *source, GdkPixmap *mask, GdkColor *fg, GdkColor *bg, gint x, gint y)
-{
-  GdkCursorPrivate *private;
-  GdkCursor *cursor;
-  Pixmap source_pixmap, mask_pixmap;
-  Cursor xcursor;
-  XColor xfg, xbg;
-  
-  source_pixmap = GDK_DRAWABLE_XID (source);
-  mask_pixmap   = GDK_DRAWABLE_XID (mask);
-
-  xfg.pixel = fg->pixel;
-  xfg.red = fg->red;
-  xfg.blue = fg->blue;
-  xfg.green = fg->green;
-  xbg.pixel = bg->pixel;
-  xbg.red = bg->red;
-  xbg.blue = bg->blue;
-  xbg.green = bg->green;
-  
-  xcursor = XCreatePixmapCursor (gdk_display, source_pixmap, mask_pixmap, &xfg, &xbg, x, y);
-  private = g_new (GdkCursorPrivate, 1);
-  private->xdisplay = gdk_display;
-  private->xcursor = xcursor;
-  cursor = (GdkCursor *) private;
-  cursor->type = GDK_CURSOR_IS_PIXMAP;
-
-  return cursor;
-}
-
-void
-gdk_cursor_destroy (GdkCursor *cursor)
-{
-  GdkCursorPrivate *private;
-
-  g_return_if_fail (cursor != NULL);
-
-  private = (GdkCursorPrivate *) cursor;
-  XFreeCursor (private->xdisplay, private->xcursor);
-
-  g_free (private);
-}
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
deleted file mode 100644 (file)
index a58da22..0000000
+++ /dev/null
@@ -1,3285 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <string.h>
-
-#include "gdk.h"          /* For gdk_flush() */
-#include "gdkdnd.h"
-#include "gdkproperty.h"
-#include "gdkprivate.h"
-#include "gdkx.h"
-
-typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
-
-typedef enum {
-  GDK_DRAG_STATUS_DRAG,
-  GDK_DRAG_STATUS_MOTION_WAIT,
-  GDK_DRAG_STATUS_ACTION_WAIT,
-  GDK_DRAG_STATUS_DROP
-} GtkDragStatus;
-
-typedef struct {
-  guint32 xid;
-  gint x, y, width, height;
-  gboolean mapped;
-} GdkCacheChild;
-
-typedef struct {
-  GList *children;
-  GHashTable *child_hash;
-  guint old_event_mask;
-} GdkWindowCache;
-
-/* Structure that holds information about a drag in progress.
- * this is used on both source and destination sides.
- */
-struct _GdkDragContextPrivate {
-  GdkDragContext context;
-
-  GdkAtom motif_selection;
-  GdkAtom xdnd_selection;
-  guint   ref_count;
-
-  guint16 last_x;              /* Coordinates from last event */
-  guint16 last_y;
-  GdkDragAction old_action;      /* The last action we sent to the source */
-  GdkDragAction old_actions;     /* The last actions we sent to the source */
-  GdkDragAction xdnd_actions;     /* What is currently set in XdndActionList */
-
-  Window dest_xid;              /* The last window we looked up */
-  Window drop_xid;            /* The (non-proxied) window that is receiving drops */
-  guint xdnd_targets_set : 1;   /* Whether we've already set XdndTypeList */
-  guint xdnd_actions_set : 1;   /* Whether we've already set XdndActionList */
-  guint xdnd_have_actions : 1; /* Whether an XdndActionList was provided */
-  guint motif_targets_set : 1;  /* Whether we've already set motif initiator info */
-  guint drag_status : 4;       /* current status of drag */
-
-  GdkWindowCache *window_cache;
-};
-
-GdkDragContext *current_dest_drag = NULL;
-
-/* Forward declarations */
-
-static void gdk_window_cache_destroy (GdkWindowCache *cache);
-
-static void     motif_read_target_table (void);
-static GdkFilterReturn motif_dnd_filter (GdkXEvent *xev,
-                                        GdkEvent  *event,
-                                        gpointer   data);
-
-static GdkFilterReturn xdnd_enter_filter (GdkXEvent *xev,
-                                         GdkEvent  *event,
-                                         gpointer   data);
-
-static GdkFilterReturn xdnd_leave_filter (GdkXEvent *xev,
-                                         GdkEvent  *event,
-                                         gpointer   data);
-
-static GdkFilterReturn xdnd_position_filter (GdkXEvent *xev,
-                                            GdkEvent  *event,
-                                            gpointer   data);
-
-static GdkFilterReturn xdnd_status_filter (GdkXEvent *xev,
-                                          GdkEvent  *event,
-                                          gpointer   data);
-
-static GdkFilterReturn xdnd_finished_filter (GdkXEvent *xev,
-                                           GdkEvent  *event,
-                                           gpointer   data);
-
-static GdkFilterReturn xdnd_drop_filter (GdkXEvent *xev,
-                                        GdkEvent  *event,
-                                        gpointer   data);
-
-static void   xdnd_manage_source_filter (GdkDragContext *context,
-                                        GdkWindow      *window,
-                                        gboolean        add_filter);
-
-/* Drag Contexts */
-
-static GList *contexts;
-
-GdkDragContext *
-gdk_drag_context_new        (void)
-{
-  GdkDragContextPrivate *result;
-
-  result = g_new0 (GdkDragContextPrivate, 1);
-
-  result->ref_count = 1;
-
-  contexts = g_list_prepend (contexts, result);
-
-  return (GdkDragContext *)result;
-}
-
-void            
-gdk_drag_context_ref (GdkDragContext *context)
-{
-  g_return_if_fail (context != NULL);
-
-  ((GdkDragContextPrivate *)context)->ref_count++;
-}
-
-void            
-gdk_drag_context_unref (GdkDragContext *context)
-{
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-
-  g_return_if_fail (context != NULL);
-  g_return_if_fail (private->ref_count > 0);
-
-  private->ref_count--;
-  
-  if (private->ref_count == 0)
-    {
-      g_dataset_destroy (private);
-      
-      g_list_free (context->targets);
-
-      if (context->source_window)
-       {
-         if ((context->protocol == GDK_DRAG_PROTO_XDND) &&
-             !context->is_source)
-           xdnd_manage_source_filter (context, context->source_window, FALSE);
-
-         gdk_window_unref (context->source_window);
-       }
-
-      if (context->dest_window)
-       gdk_window_unref (context->dest_window);
-
-      if (private->window_cache)
-       gdk_window_cache_destroy (private->window_cache);
-
-      contexts = g_list_remove (contexts, private);
-      g_free (private);
-    }
-}
-
-static GdkDragContext *
-gdk_drag_context_find (gboolean is_source,
-                      Window   source_xid,
-                      Window   dest_xid)
-{
-  GList *tmp_list = contexts;
-  GdkDragContext *context;
-  GdkDragContextPrivate *private;
-  Window context_dest_xid;
-
-  while (tmp_list)
-    {
-      context = (GdkDragContext *)tmp_list->data;
-      private = (GdkDragContextPrivate *)context;
-
-      context_dest_xid = context->dest_window ? 
-                          (private->drop_xid ?
-                             private->drop_xid :
-                             GDK_WINDOW_XWINDOW (context->dest_window)) :
-                          None;
-
-      if ((!context->is_source == !is_source) &&
-         ((source_xid == None) || (context->source_window &&
-           (GDK_WINDOW_XWINDOW (context->source_window) == source_xid))) &&
-         ((dest_xid == None) || (context_dest_xid == dest_xid)))
-       return context;
-      
-      tmp_list = tmp_list->next;
-    }
-  
-  return NULL;
-}
-
-/* Utility functions */
-
-static void
-gdk_window_cache_add (GdkWindowCache *cache,
-                     guint32 xid,
-                     gint x, gint y, gint width, gint height, 
-                     gboolean mapped)
-{
-  GdkCacheChild *child = g_new (GdkCacheChild, 1);
-
-  child->xid = xid;
-  child->x = x;
-  child->y = y;
-  child->width = width;
-  child->height = height;
-  child->mapped = mapped;
-
-  cache->children = g_list_prepend (cache->children, child);
-  g_hash_table_insert (cache->child_hash, GUINT_TO_POINTER (xid), 
-                      cache->children);
-}
-
-static GdkFilterReturn
-gdk_window_cache_filter (GdkXEvent *xev,
-                        GdkEvent  *event,
-                        gpointer   data)
-{
-  XEvent *xevent = (XEvent *)xev;
-  GdkWindowCache *cache = data;
-
-  switch (xevent->type)
-    {
-    case CirculateNotify:
-      break;
-    case ConfigureNotify:
-      {
-       XConfigureEvent *xce = &xevent->xconfigure;
-       GList *node;
-
-       node = g_hash_table_lookup (cache->child_hash, 
-                                   GUINT_TO_POINTER (xce->window));
-       if (node) 
-         {
-           GdkCacheChild *child = node->data;
-           child->x = xce->x; 
-           child->y = xce->y;
-           child->width = xce->width; 
-           child->height = xce->height;
-           if (xce->above == None && (node->next))
-             {
-               GList *last = g_list_last (cache->children);
-               cache->children = g_list_remove_link (cache->children, node);
-               last->next = node;
-               node->next = NULL;
-               node->prev = last;
-             }
-           else
-             {
-               GList *above_node = g_hash_table_lookup (cache->child_hash, 
-                                                        GUINT_TO_POINTER (xce->above));
-               if (above_node && node->prev != above_node)
-                 {
-                   cache->children = g_list_remove_link (cache->children, node);
-                   node->next = above_node->next;
-                   if (node->next)
-                     node->next->prev = node;
-                   node->prev = above_node;
-                   above_node->next = node;
-                 }
-             }
-         }
-       break;
-      }
-    case CreateNotify:
-      {
-       XCreateWindowEvent *xcwe = &xevent->xcreatewindow;
-
-       if (!g_hash_table_lookup (cache->child_hash, 
-                                 GUINT_TO_POINTER (xcwe->window))) 
-         gdk_window_cache_add (cache, xcwe->window, 
-                               xcwe->x, xcwe->y, xcwe->width, xcwe->height,
-                               FALSE);
-       break;
-      }
-    case DestroyNotify:
-      {
-       XDestroyWindowEvent *xdwe = &xevent->xdestroywindow;
-       GList *node;
-
-       node = g_hash_table_lookup (cache->child_hash, 
-                                   GUINT_TO_POINTER (xdwe->window));
-       if (node) 
-         {
-           g_hash_table_remove (cache->child_hash,
-                                GUINT_TO_POINTER (xdwe->window));
-           cache->children = g_list_remove_link (cache->children, node);
-           g_free (node->data);
-           g_list_free_1 (node);
-         }
-       break;
-      }
-    case MapNotify:
-      {
-       XMapEvent *xme = &xevent->xmap;
-       GList *node;
-
-       node = g_hash_table_lookup (cache->child_hash, 
-                                   GUINT_TO_POINTER (xme->window));
-       if (node) 
-         {
-           GdkCacheChild *child = node->data;
-           child->mapped = TRUE;
-         }
-       break;
-      }
-    case ReparentNotify:
-      break;
-    case UnmapNotify:
-      {
-       XMapEvent *xume = &xevent->xmap;
-       GList *node;
-
-       node = g_hash_table_lookup (cache->child_hash, 
-                                   GUINT_TO_POINTER (xume->window));
-       if (node) 
-         {
-           GdkCacheChild *child = node->data;
-           child->mapped = FALSE;
-         }
-       break;
-      }
-    default:
-      return GDK_FILTER_CONTINUE;
-    }
-  return GDK_FILTER_REMOVE;
-}
-
-static GdkWindowCache *
-gdk_window_cache_new (void)
-{
-  XWindowAttributes xwa;
-  Window root, parent, *children;
-  unsigned int nchildren;
-  int i;
-  
-  gint old_warnings = gdk_error_warnings;
-  
-  GdkWindowCache *result = g_new (GdkWindowCache, 1);
-
-  result->children = NULL;
-  result->child_hash = g_hash_table_new (g_direct_hash, NULL);
-
-  XGetWindowAttributes (gdk_display, gdk_root_window, &xwa);
-  result->old_event_mask = xwa.your_event_mask;
-  XSelectInput (gdk_display, gdk_root_window,
-               result->old_event_mask | SubstructureNotifyMask);
-  gdk_window_add_filter ((GdkWindow *)&gdk_root_parent, 
-                        gdk_window_cache_filter, result);
-  
-  gdk_error_code = 0;
-  gdk_error_warnings = 0;
-
-  if (XQueryTree(gdk_display, gdk_root_window, 
-                &root, &parent, &children, &nchildren) == 0)
-    return result;
-  
-  for (i = 0; i < nchildren ; i++)
-    {
-      XGetWindowAttributes (gdk_display, children[i], &xwa);
-
-      gdk_window_cache_add (result, children[i],
-                           xwa.x, xwa.y, xwa.width, xwa.height,
-                           xwa.map_state != IsUnmapped);
-
-      if (gdk_error_code)
-       gdk_error_code = 0;
-      else
-       {
-         gdk_window_cache_add (result, children[i],
-                               xwa.x, xwa.y, xwa.width, xwa.height,
-                               (xwa.map_state != IsUnmapped));
-       }
-    }
-
-  XFree (children);
-
-  gdk_error_warnings = old_warnings;
-
-  return result;
-}
-
-static void
-gdk_window_cache_destroy (GdkWindowCache *cache)
-{
-  XSelectInput (gdk_display, gdk_root_window, cache->old_event_mask);
-  gdk_window_remove_filter ((GdkWindow *)&gdk_root_parent, 
-                           gdk_window_cache_filter, cache);
-
-  g_list_foreach (cache->children, (GFunc)g_free, NULL);
-  g_list_free (cache->children);
-  g_hash_table_destroy (cache->child_hash);
-
-  g_free (cache);
-}
-
-static Window
-get_client_window_at_coords_recurse (Window  win,
-                                    gint    x,
-                                    gint    y)
-{
-  Window root, tmp_parent, *children;
-  unsigned int nchildren;
-  int i;
-  Window child = None;
-  Atom type = None;
-  int format;
-  unsigned long nitems, after;
-  unsigned char *data;
-  
-  static Atom wm_state_atom = None;
-
-  if (!wm_state_atom)
-    wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE);
-    
-  XGetWindowProperty (gdk_display, win, 
-                     wm_state_atom, 0, 0, False, AnyPropertyType,
-                     &type, &format, &nitems, &after, &data);
-  
-  if (gdk_error_code)
-    {
-      gdk_error_code = 0;
-
-      return None;
-    }
-
-  if (type != None)
-    {
-      XFree (data);
-      return win;
-    }
-
-#if 0
-  /* This is beautiful! Damn Enlightenment and click-to-focus */
-  XTranslateCoordinates (gdk_display, gdk_root_window, win,
-                        x_root, y_root, &dest_x, &dest_y, &child);
-
-  if (gdk_error_code)
-    {
-      gdk_error_code = 0;
-
-      return None;
-    }
-  
-#else
-  if (XQueryTree(gdk_display, win,
-                &root, &tmp_parent, &children, &nchildren) == 0)
-    return 0;
-
-  if (!gdk_error_code)
-    {
-      for (i = nchildren - 1; (i >= 0) && (child == None); i--)
-       {
-         XWindowAttributes xwa;
-         
-         XGetWindowAttributes (gdk_display, children[i], &xwa);
-         
-         if (gdk_error_code)
-           gdk_error_code = 0;
-         else if ((xwa.map_state == IsViewable) && (xwa.class == InputOutput) &&
-                  (x >= xwa.x) && (x < xwa.x + (gint)xwa.width) &&
-                  (y >= xwa.y) && (y < xwa.y + (gint)xwa.height))
-           {
-             x -= xwa.x;
-             y -= xwa.y;
-             child = children[i];
-           }
-       }
-      
-      XFree (children);
-    }
-  else
-    gdk_error_code = 0;
-#endif  
-
-  if (child)
-    return get_client_window_at_coords_recurse (child, x, y);
-  else
-    return None;
-}
-
-static Window 
-get_client_window_at_coords (GdkWindowCache *cache,
-                            Window          ignore,
-                            gint            x_root,
-                            gint            y_root)
-{
-  GList *tmp_list;
-  Window retval = None;
-
-  gint old_warnings = gdk_error_warnings;
-  
-  gdk_error_code = 0;
-  gdk_error_warnings = 0;
-
-  tmp_list = cache->children;
-
-  while (tmp_list && !retval)
-    {
-      GdkCacheChild *child = tmp_list->data;
-
-      if ((child->xid != ignore) && (child->mapped))
-       {
-         if ((x_root >= child->x) && (x_root < child->x + child->width) &&
-             (y_root >= child->y) && (y_root < child->y + child->height))
-           {
-             retval = get_client_window_at_coords_recurse (child->xid,
-                                                           x_root - child->x, 
-                                                           y_root - child->y);
-             if (!retval)
-               retval = child->xid;
-           }
-         
-       }
-      tmp_list = tmp_list->next;
-    }
-
-  gdk_error_warnings = old_warnings;
-  if (retval)
-    return retval;
-  else
-    return gdk_root_window;
-}
-
-#if 0
-static Window
-get_client_window_at_coords_recurse (Window  win,
-                                    gint    x_root,
-                                    gint    y_root)
-{
-  Window child;
-  Atom type = None;
-  int format;
-  unsigned long nitems, after;
-  unsigned char *data;
-  int dest_x, dest_y;
-  
-  static Atom wm_state_atom = None;
-
-  if (!wm_state_atom)
-    wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE);
-    
-  XGetWindowProperty (gdk_display, win, 
-                     wm_state_atom, 0, 0, False, AnyPropertyType,
-                     &type, &format, &nitems, &after, &data);
-  
-  if (gdk_error_code)
-    {
-      gdk_error_code = 0;
-
-      return None;
-    }
-
-  if (type != None)
-    {
-      XFree (data);
-      return win;
-    }
-
-  XTranslateCoordinates (gdk_display, gdk_root_window, win,
-                        x_root, y_root, &dest_x, &dest_y, &child);
-
-  if (gdk_error_code)
-    {
-      gdk_error_code = 0;
-
-      return None;
-    }
-
-  if (child)
-    return get_client_window_at_coords_recurse (child, x_root, y_root);
-  else
-    return None;
-}
-
-static Window 
-get_client_window_at_coords (Window  ignore,
-                            gint    x_root,
-                            gint    y_root)
-{
-  Window root, parent, *children;
-  unsigned int nchildren;
-  int i;
-  Window retval = None;
-  
-  gint old_warnings = gdk_error_warnings;
-  
-  gdk_error_code = 0;
-  gdk_error_warnings = 0;
-
-  if (XQueryTree(gdk_display, gdk_root_window, 
-                &root, &parent, &children, &nchildren) == 0)
-    return 0;
-
-  for (i = nchildren - 1; (i >= 0) && (retval == None); i--)
-    {
-      if (children[i] != ignore)
-       {
-         XWindowAttributes xwa;
-
-         XGetWindowAttributes (gdk_display, children[i], &xwa);
-
-         if (gdk_error_code)
-           gdk_error_code = 0;
-         else if ((xwa.map_state == IsViewable) &&
-                  (x_root >= xwa.x) && (x_root < xwa.x + (gint)xwa.width) &&
-                  (y_root >= xwa.y) && (y_root < xwa.y + (gint)xwa.height))
-           {
-             retval = get_client_window_at_coords_recurse (children[i],
-                                                           x_root, y_root);
-             if (!retval)
-               retval = children[i];
-           }
-       }
-    }
-
-  XFree (children);
-
-  gdk_error_warnings = old_warnings;
-  if (retval)
-    return retval;
-  else
-    return gdk_root_window;
-}
-#endif
-
-/*************************************************************
- ***************************** MOTIF *************************
- *************************************************************/
-
-/* values used in the message type for Motif DND */
-enum {
-    XmTOP_LEVEL_ENTER,
-    XmTOP_LEVEL_LEAVE,
-    XmDRAG_MOTION,
-    XmDROP_SITE_ENTER,
-    XmDROP_SITE_LEAVE,
-    XmDROP_START,
-    XmDROP_FINISH,
-    XmDRAG_DROP_FINISH,
-    XmOPERATION_CHANGED
-};
-
-/* Values used to specify type of protocol to use */
-enum {
-    XmDRAG_NONE,
-    XmDRAG_DROP_ONLY,
-    XmDRAG_PREFER_PREREGISTER,
-    XmDRAG_PREREGISTER,
-    XmDRAG_PREFER_DYNAMIC,
-    XmDRAG_DYNAMIC,
-    XmDRAG_PREFER_RECEIVER
-};
-
-/* Operation codes */
-enum {
-  XmDROP_NOOP,
-  XmDROP_MOVE = 0x01,
-  XmDROP_COPY = 0x02,
-  XmDROP_LINK = 0x04
-};
-
-/* Drop site status */
-enum {
-  XmNO_DROP_SITE = 0x01,
-  XmDROP_SITE_INVALID = 0x02,
-  XmDROP_SITE_VALID = 0x03
-};
-
-/* completion status */
-enum {
-  XmDROP,
-  XmDROP_HELP,
-  XmDROP_CANCEL,
-  XmDROP_INTERRUPT
-};
-
-/* Static data for MOTIF DND */
-static GList **motif_target_lists = NULL;
-static gint motif_n_target_lists = -1;
-
-/* Byte swapping routines. The motif specification leaves it
- * up to us to save a few bytes in the client messages
- */
-static gchar local_byte_order = '\0';
-
-#ifdef G_ENABLE_DEBUG
-static void
-print_target_list (GList *targets)
-{
-  while (targets)
-    {
-      gchar *name = gdk_atom_name (GPOINTER_TO_INT (targets->data));
-      g_message ("\t%s", name);
-      g_free (name);
-      targets = targets->next;
-    }
-}
-#endif /* G_ENABLE_DEBUG */
-
-static void
-init_byte_order (void)
-{
-  guint32 myint = 0x01020304;
-  local_byte_order = (*(gchar *)&myint == 1) ? 'B' : 'l';
-}
-
-static guint16
-card16_to_host (guint16 x, gchar byte_order) {
-  if (byte_order == local_byte_order)
-    return x;
-  else
-    return (x << 8) | (x >> 8);
-}
-
-static guint32
-card32_to_host (guint32 x, gchar byte_order) {
-  if (byte_order == local_byte_order)
-    return x;
-  else
-    return (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
-}
-
-/* Motif packs together fields of varying length into the
- * client message. We can't rely on accessing these
- * through data.s[], data.l[], etc, because on some architectures
- * (i.e., Alpha) these won't be valid for format == 8. 
- */
-
-#define MOTIF_XCLIENT_BYTE(xevent,i) \
-  (xevent)->xclient.data.b[i]
-#define MOTIF_XCLIENT_SHORT(xevent,i) \
-  ((gint16 *)&((xevent)->xclient.data.b[0]))[i]
-#define MOTIF_XCLIENT_LONG(xevent,i) \
-  ((gint32 *)&((xevent)->xclient.data.b[0]))[i]
-
-#define MOTIF_UNPACK_BYTE(xevent,i) MOTIF_XCLIENT_BYTE(xevent,i)
-#define MOTIF_UNPACK_SHORT(xevent,i) \
-  card16_to_host (MOTIF_XCLIENT_SHORT(xevent,i), MOTIF_XCLIENT_BYTE(xevent, 1))
-#define MOTIF_UNPACK_LONG(xevent,i) \
-  card32_to_host (MOTIF_XCLIENT_LONG(xevent,i), MOTIF_XCLIENT_BYTE(xevent, 1))
-
-/***** Dest side ***********/
-
-/* Property placed on source windows */
-typedef struct _MotifDragInitiatorInfo {
-  guint8 byte_order;
-  guint8 protocol_version;
-  guint16 targets_index;
-  guint32 selection_atom;
-} MotifDragInitiatorInfo;
-
-/* Header for target table on the drag window */
-typedef struct _MotifTargetTableHeader {
-  guchar byte_order;
-  guchar protocol_version;
-  guint16 n_lists;
-  guint32 total_size;
-} MotifTargetTableHeader;
-
-/* Property placed on target windows */
-typedef struct _MotifDragReceiverInfo {
-  guint8 byte_order;
-  guint8 protocol_version;
-  guint8 protocol_style;
-  guint8 pad;
-  guint32 proxy_window;
-  guint16 num_drop_sites;
-  guint16 padding;
-  guint32 total_size;
-} MotifDragReceiverInfo;
-
-static Window motif_drag_window = None;
-static GdkWindow *motif_drag_gdk_window = NULL;
-
-static GdkAtom motif_drag_targets_atom = GDK_NONE;
-static GdkAtom motif_drag_receiver_info_atom = GDK_NONE;
-
-/* Target table handling */
-
-GdkFilterReturn
-motif_drag_window_filter (GdkXEvent *xevent,
-                         GdkEvent  *event,
-                         gpointer data)
-{
-  XEvent *xev = (XEvent *)xevent;
-
-  switch (xev->xany.type)
-    {
-    case DestroyNotify:
-      motif_drag_window = None;
-      motif_drag_gdk_window = NULL;
-      break;
-    case PropertyNotify:
-      if (motif_target_lists &&
-         motif_drag_targets_atom &&
-         (xev->xproperty.atom == motif_drag_targets_atom))
-       motif_read_target_table();
-      break;
-    }
-  return GDK_FILTER_REMOVE;
-}
-
-static Atom motif_drag_window_atom = GDK_NONE;
-
-static Window
-motif_lookup_drag_window (Display *display)
-{
-  Window retval = None;
-  gulong bytes_after, nitems;
-  GdkAtom type;
-  gint format;
-  guchar *data;
-
-  XGetWindowProperty (gdk_display, gdk_root_window, motif_drag_window_atom,
-                     0, 1, FALSE,
-                     XA_WINDOW, &type, &format, &nitems, &bytes_after,
-                     &data);
-  
-  if ((format == 32) && (nitems == 1) && (bytes_after == 0))
-    {
-      retval = *(Window *)data;
-      GDK_NOTE(DND, 
-              g_message ("Found drag window %#lx\n", motif_drag_window));
-    }
-
-  if (type != None)
-    XFree (data);
-
-  return retval;
-}
-
-/* Finds the window where global Motif drag information is stored.
- * If it doesn't exist and 'create' is TRUE, create one.
- */
-Window 
-motif_find_drag_window (gboolean create)
-{
-  if (!motif_drag_window)
-    {
-      if (!motif_drag_window_atom)
-       motif_drag_window_atom = gdk_atom_intern ("_MOTIF_DRAG_WINDOW", TRUE);
-
-      motif_drag_window = motif_lookup_drag_window (gdk_display);
-      
-      if (!motif_drag_window && create)
-       {
-         /* Create a persistant window. (Copied from LessTif) */
-         
-         Display *display;
-         XSetWindowAttributes attr;
-         display = XOpenDisplay (gdk_display_name);
-         XSetCloseDownMode (display, RetainPermanent);
-
-         XGrabServer (display);
-         
-         motif_drag_window = motif_lookup_drag_window (display);
-
-         if (!motif_drag_window)
-           {
-             attr.override_redirect = True;
-             attr.event_mask = PropertyChangeMask;
-             
-             motif_drag_window = 
-               XCreateWindow(display, DefaultRootWindow(display),
-                             -100, -100, 10, 10, 0, 0,
-                             InputOnly, CopyFromParent,
-                             (CWOverrideRedirect | CWEventMask), &attr);
-             
-             GDK_NOTE (DND,
-                       g_message ("Created drag window %#lx\n", motif_drag_window));
-             
-             XChangeProperty (display, gdk_root_window,
-                              motif_drag_window_atom, XA_WINDOW,
-                              32, PropModeReplace,
-                              (guchar *)&motif_drag_window_atom, 1);
-
-           }
-         XUngrabServer (display);
-         XCloseDisplay (display);
-       }
-
-      /* There is a miniscule race condition here if the drag window
-       * gets destroyed exactly now.
-       */
-      if (motif_drag_window)
-       {
-         motif_drag_gdk_window = gdk_window_foreign_new (motif_drag_window);
-         gdk_window_add_filter (motif_drag_gdk_window,
-                                motif_drag_window_filter,
-                                NULL);
-       }
-    }
-
-  return motif_drag_window;
-}
-
-static void 
-motif_read_target_table (void)
-{
-  gulong bytes_after, nitems;
-  GdkAtom type;
-  gint format;
-  gint i, j;
-
-  if (!motif_drag_targets_atom)
-    motif_drag_targets_atom = gdk_atom_intern ("_MOTIF_DRAG_TARGETS", FALSE);
-
-  if (motif_target_lists)
-    {
-      for (i=0; i<motif_n_target_lists; i++)
-       g_list_free (motif_target_lists[i]);
-      
-      g_free (motif_target_lists);
-      motif_target_lists = NULL;
-      motif_n_target_lists = 0;
-    }
-
-  if (motif_find_drag_window (FALSE))
-    {
-      MotifTargetTableHeader *header = NULL;
-      guchar *target_bytes = NULL;
-      guchar *p;
-      gboolean success = FALSE;
-
-      XGetWindowProperty (gdk_display, motif_drag_window, 
-                         motif_drag_targets_atom,
-                         0, (sizeof(MotifTargetTableHeader)+3)/4, FALSE,
-                         motif_drag_targets_atom, 
-                         &type, &format, &nitems, &bytes_after,
-                         (guchar **)&header);
-
-      if ((format != 8) || (nitems < sizeof (MotifTargetTableHeader)))
-       goto error;
-
-      header->n_lists = card16_to_host (header->n_lists, header->byte_order);
-      header->total_size = card32_to_host (header->total_size, header->byte_order);
-
-      XGetWindowProperty (gdk_display, motif_drag_window, motif_drag_targets_atom,
-                         (sizeof(MotifTargetTableHeader)+3)/4, 
-                         (header->total_size + 3)/4 - (sizeof(MotifTargetTableHeader) + 3)/4,
-                         FALSE,
-                         motif_drag_targets_atom, &type, &format, &nitems, 
-                         &bytes_after, &target_bytes);
-      
-      if ((format != 8) || (bytes_after != 0) || 
-         (nitems != header->total_size - sizeof(MotifTargetTableHeader)))
-         goto error;
-
-      motif_n_target_lists = header->n_lists;
-      motif_target_lists = g_new0 (GList *, motif_n_target_lists);
-
-      p = target_bytes;
-      for (i=0; i<header->n_lists; i++)
-       {
-         gint n_targets;
-         guint32 *targets;
-         
-         if (p + sizeof(guint16) - target_bytes > nitems)
-           goto error;
-
-         n_targets = card16_to_host (*(gushort *)p, header->byte_order);
-
-         /* We need to make a copy of the targets, since it may
-          * be unaligned
-          */
-         targets = g_new (guint32, n_targets);
-         memcpy (targets, p + sizeof(guint16), sizeof(guint32) * n_targets);
-
-         p +=  sizeof(guint16) + n_targets * sizeof(guint32);
-         if (p - target_bytes > nitems)
-           goto error;
-
-         for (j=0; j<n_targets; j++)
-           motif_target_lists[i] = 
-             g_list_prepend (motif_target_lists[i],
-                             GUINT_TO_POINTER (card32_to_host (targets[j], 
-                                                               header->byte_order)));
-         g_free (targets);
-         motif_target_lists[i] = g_list_reverse (motif_target_lists[i]);
-       }
-
-      success = TRUE;
-      
-    error:
-      if (header)
-       XFree (header);
-      
-      if (target_bytes)
-       XFree (target_bytes);
-
-      if (!success)
-       {
-         if (motif_target_lists)
-           {
-             g_free (motif_target_lists);
-             motif_target_lists = NULL;
-             motif_n_target_lists = 0;
-           }
-         g_warning ("Error reading Motif target table\n");
-       }
-    }
-}
-
-static gint
-targets_sort_func (gconstpointer a, gconstpointer b)
-{
-  return (GPOINTER_TO_UINT (a) < GPOINTER_TO_UINT (b)) ?
-    -1 : ((GPOINTER_TO_UINT (a) > GPOINTER_TO_UINT (b)) ? 1 : 0);
-}
-
-/* Check if given (sorted) list is in the targets table */
-static gboolean
-motif_target_table_check (GList *sorted)
-{
-  GList *tmp_list1, *tmp_list2;
-  gint i;
-
-  for (i=0; i<motif_n_target_lists; i++)
-    {
-      tmp_list1 = motif_target_lists[i];
-      tmp_list2 = sorted;
-      
-      while (tmp_list1 && tmp_list2)
-       {
-         if (tmp_list1->data != tmp_list2->data)
-           break;
-
-         tmp_list1 = tmp_list1->next;
-         tmp_list2 = tmp_list2->next;
-       }
-      if (!tmp_list1 && !tmp_list2)    /* Found it */
-       return i;
-    }
-
-  return -1;
-}
-
-static gint
-motif_add_to_target_table (GList *targets)
-{
-  GList *sorted = NULL;
-  gint index = -1;
-  gint i;
-  GList *tmp_list;
-  
-  /* make a sorted copy of the list */
-  
-  while (targets)
-    {
-      sorted = g_list_insert_sorted (sorted, targets->data, targets_sort_func);
-      targets = targets->next;
-    }
-
-  /* First check if it is their already */
-
-  if (motif_target_lists)
-    index = motif_target_table_check (sorted);
-
-  /* We need to grab the server while doing this, to ensure
-   * atomiticity. Ugh
-   */
-
-  if (index < 0)
-    {
-      /* We need to make sure that it exists _before_ we grab the
-       * server, since we can't open a new connection after we
-       * grab the server. 
-       */
-      motif_find_drag_window (TRUE);
-
-      XGrabServer(gdk_display);
-      motif_read_target_table();
-    
-      /* Check again, in case it was added in the meantime */
-      
-      if (motif_target_lists)
-       index =  motif_target_table_check (sorted);
-
-      if (index < 0)
-       {
-         guint32 total_size = 0;
-         guchar *data;
-         guchar *p;
-         guint16 *p16;
-         MotifTargetTableHeader *header;
-         
-         if (!motif_target_lists)
-           {
-             motif_target_lists = g_new (GList *, 1);
-             motif_n_target_lists = 1;
-           }
-         else
-           {
-             motif_n_target_lists++;
-             motif_target_lists = g_realloc (motif_target_lists,
-                                             sizeof(GList *) * motif_n_target_lists);
-           }
-         motif_target_lists[motif_n_target_lists - 1] = sorted;
-         sorted = NULL;
-         index = motif_n_target_lists - 1;
-
-         total_size = sizeof (MotifTargetTableHeader);
-         for (i = 0; i < motif_n_target_lists ; i++)
-           total_size += sizeof(guint16) + sizeof(guint32) * g_list_length (motif_target_lists[i]);
-
-         data = g_malloc (total_size);
-
-         header = (MotifTargetTableHeader *)data;
-         p = data + sizeof(MotifTargetTableHeader);
-
-         header->byte_order = local_byte_order;
-         header->protocol_version = 0;
-         header->n_lists = motif_n_target_lists;
-         header->total_size = total_size;
-
-         for (i = 0; i < motif_n_target_lists ; i++)
-           {
-             guint16 n_targets = g_list_length (motif_target_lists[i]);
-             guint32 *targets = g_new (guint32, n_targets);
-             guint32 *p32 = targets;
-             
-             tmp_list = motif_target_lists[i];
-             while (tmp_list)
-               {
-                 *p32 = GPOINTER_TO_UINT (tmp_list->data);
-                 
-                 tmp_list = tmp_list->next;
-                 p32++;
-               }
-
-             p16 = (guint16 *)p;
-             p += sizeof(guint16);
-
-             memcpy (p, targets, n_targets * sizeof(guint32));
-
-             *p16 = n_targets;
-             p += sizeof(guint32) * n_targets;
-             g_free (targets);
-           }
-
-         XChangeProperty (gdk_display, motif_drag_window,
-                          motif_drag_targets_atom,
-                          motif_drag_targets_atom,
-                          8, PropModeReplace,
-                          data, total_size);
-       }
-      XUngrabServer(gdk_display);
-    }
-
-  g_list_free (sorted);
-  return index;
-}
-
-/* Translate flags */
-
-static void
-motif_dnd_translate_flags (GdkDragContext *context, guint16 flags)
-{
-  guint recommended_op = flags & 0x000f;
-  guint possible_ops = (flags & 0x0f0) >> 4;
-  
-  switch (recommended_op)
-    {
-    case XmDROP_MOVE:
-      context->suggested_action = GDK_ACTION_MOVE;
-      break;
-    case XmDROP_COPY:
-      context->suggested_action = GDK_ACTION_COPY;
-      break;
-    case XmDROP_LINK:
-      context->suggested_action = GDK_ACTION_LINK;
-      break;
-    default:
-      context->suggested_action = GDK_ACTION_COPY;
-      break;
-    }
-
-  context->actions = 0;
-  if (possible_ops & XmDROP_MOVE)
-    context->actions |= GDK_ACTION_MOVE;
-  if (possible_ops & XmDROP_COPY)
-    context->actions |= GDK_ACTION_COPY;
-  if (possible_ops & XmDROP_LINK)
-    context->actions |= GDK_ACTION_LINK;
-}
-
-static guint16
-motif_dnd_get_flags (GdkDragContext *context)
-{
-  guint16 flags = 0;
-  
-  switch (context->suggested_action)
-    {
-    case GDK_ACTION_MOVE:
-      flags = XmDROP_MOVE;
-      break;
-    case GDK_ACTION_COPY:
-      flags = XmDROP_COPY;
-      break;
-    case GDK_ACTION_LINK:
-      flags = XmDROP_LINK;
-      break;
-    default:
-      flags = XmDROP_NOOP;
-      break;
-    }
-  
-  if (context->actions & GDK_ACTION_MOVE)
-    flags |= XmDROP_MOVE << 8;
-  if (context->actions & GDK_ACTION_COPY)
-    flags |= XmDROP_COPY << 8;
-  if (context->actions & GDK_ACTION_LINK)
-    flags |= XmDROP_LINK << 8;
-
-  return flags;
-}
-
-/* Source Side */
-
-static void
-motif_set_targets (GdkDragContext *context)
-{
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-  MotifDragInitiatorInfo info;
-  gint i;
-  static GdkAtom motif_drag_initiator_info = GDK_NONE;
-
-  if (!motif_drag_initiator_info)
-    motif_drag_initiator_info = gdk_atom_intern ("_MOTIF_DRAG_INITIATOR_INFO", FALSE);
-
-  info.byte_order = local_byte_order;
-  info.protocol_version = 0;
-  
-  info.targets_index = motif_add_to_target_table (context->targets);
-
-  for (i=0; ; i++)
-    {
-      gchar buf[20];
-      g_snprintf(buf, 20, "_GDK_SELECTION_%d", i);
-      
-      private->motif_selection = gdk_atom_intern (buf, FALSE);
-      if (!XGetSelectionOwner (gdk_display, private->motif_selection))
-       break;
-    }
-
-  info.selection_atom = private->motif_selection;
-
-  XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
-                  GDK_WINDOW_XWINDOW (context->source_window),
-                  private->motif_selection,
-                  motif_drag_initiator_info, 8, PropModeReplace,
-                  (guchar *)&info, sizeof (info));
-
-  private->motif_targets_set = 1;
-}
-
-guint32
-motif_check_dest (Window win)
-{
-  gboolean retval = FALSE;
-  MotifDragReceiverInfo *info;
-  Atom type = None;
-  int format;
-  unsigned long nitems, after;
-
-  if (!motif_drag_receiver_info_atom)
-    motif_drag_receiver_info_atom = gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE);
-
-  XGetWindowProperty (gdk_display, win, 
-                     motif_drag_receiver_info_atom, 
-                     0, (sizeof(*info)+3)/4, False, AnyPropertyType,
-                     &type, &format, &nitems, &after, 
-                     (guchar **)&info);
-  
-  if (type != None)
-    {
-      if ((format == 8) && (nitems == sizeof(*info)))
-       {
-         if ((info->protocol_version == 0) &&
-             ((info->protocol_style == XmDRAG_PREFER_PREREGISTER) ||
-              (info->protocol_style == XmDRAG_PREFER_DYNAMIC) ||
-              (info->protocol_style == XmDRAG_DYNAMIC)))
-           retval = TRUE;
-       }
-      else
-       {
-         GDK_NOTE (DND, 
-                   g_warning ("Invalid Motif drag receiver property on window %ld\n", win));
-       }
-
-      XFree (info);
-    }
-
-  return retval ? win : GDK_NONE;
-  
-}
-
-static void
-motif_send_enter (GdkDragContext  *context,
-                 guint32          time)
-{
-  XEvent xev;
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-
-  xev.xclient.type = ClientMessage;
-  xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
-  xev.xclient.format = 8;
-  xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-
-  MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_ENTER;
-  MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
-  MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
-  MOTIF_XCLIENT_LONG (&xev, 1) = time;
-  MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XWINDOW (context->source_window);
-
-  if (!private->motif_targets_set)
-    motif_set_targets (context);
-
-  MOTIF_XCLIENT_LONG (&xev, 3) = private->motif_selection;
-
-  if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
-                       FALSE, 0, &xev))
-    GDK_NOTE (DND, 
-             g_message ("Send event to %lx failed",
-                        GDK_WINDOW_XWINDOW (context->dest_window)));
-}
-
-static void
-motif_send_leave (GdkDragContext  *context,
-                 guint32          time)
-{
-  XEvent xev;
-
-  xev.xclient.type = ClientMessage;
-  xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
-  xev.xclient.format = 8;
-  xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-
-  MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_LEAVE;
-  MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
-  MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
-  MOTIF_XCLIENT_LONG (&xev, 1) = time;
-  MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XWINDOW (context->source_window);
-  MOTIF_XCLIENT_LONG (&xev, 3) = 0;
-
-  if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
-                       FALSE, 0, &xev))
-    GDK_NOTE (DND, 
-             g_message ("Send event to %lx failed",
-                        GDK_WINDOW_XWINDOW (context->dest_window)));
-}
-
-static gboolean
-motif_send_motion (GdkDragContext  *context,
-                   gint            x_root, 
-                   gint            y_root,
-                   GdkDragAction   action,
-                   guint32         time)
-{
-  gboolean retval;
-  XEvent xev;
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-
-  xev.xclient.type = ClientMessage;
-  xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
-  xev.xclient.format = 8;
-  xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-
-  MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
-  MOTIF_XCLIENT_SHORT (&xev, 1) = motif_dnd_get_flags (context);
-  MOTIF_XCLIENT_LONG (&xev, 1) = time;
-
-  if ((context->suggested_action != private->old_action) ||
-      (context->actions != private->old_actions))
-    {
-      MOTIF_XCLIENT_BYTE (&xev, 0) = XmOPERATION_CHANGED;
-
-      /* private->drag_status = GDK_DRAG_STATUS_ACTION_WAIT; */
-      retval = TRUE;
-    }
-  else
-    {
-      MOTIF_XCLIENT_BYTE (&xev, 0) = XmDRAG_MOTION;
-
-      MOTIF_XCLIENT_SHORT (&xev, 4) = x_root;
-      MOTIF_XCLIENT_SHORT (&xev, 5) = y_root;
-      
-      private->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
-      retval = FALSE;
-    }
-
-  if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
-                       FALSE, 0, &xev))
-    GDK_NOTE (DND, 
-             g_message ("Send event to %lx failed",
-                        GDK_WINDOW_XWINDOW (context->dest_window)));
-
-  return retval;
-}
-
-static void
-motif_send_drop (GdkDragContext *context, guint32 time)
-{
-  XEvent xev;
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-
-  xev.xclient.type = ClientMessage;
-  xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
-  xev.xclient.format = 8;
-  xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-
-  MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START;
-  MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
-  MOTIF_XCLIENT_SHORT (&xev, 1) = motif_dnd_get_flags (context);
-  MOTIF_XCLIENT_LONG (&xev, 1)  = time;
-
-  MOTIF_XCLIENT_SHORT (&xev, 4) = private->last_x;
-  MOTIF_XCLIENT_SHORT (&xev, 5) = private->last_y;
-
-  MOTIF_XCLIENT_LONG (&xev, 3)  = private->motif_selection;
-  MOTIF_XCLIENT_LONG (&xev, 4)  = GDK_WINDOW_XWINDOW (context->source_window);
-
-  if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
-                       FALSE, 0, &xev))
-    GDK_NOTE (DND, 
-             g_message ("Send event to %lx failed",
-                        GDK_WINDOW_XWINDOW (context->dest_window)));
-}
-
-/* Target Side */
-
-static gboolean
-motif_read_initiator_info (Window source_window, 
-                          Atom atom,
-                          GList  **targets,
-                          GdkAtom *selection)
-{
-  GList *tmp_list;
-  static GdkAtom motif_drag_initiator_info = GDK_NONE;
-  GdkAtom type;
-  gint format;
-  gulong nitems;
-  gulong bytes_after;
-
-  MotifDragInitiatorInfo *initiator_info;
-
-  if (!motif_drag_initiator_info)
-    motif_drag_initiator_info = gdk_atom_intern ("_MOTIF_DRAG_INITIATOR_INFO", FALSE);
-
-  XGetWindowProperty (gdk_display, source_window, atom,
-                     0, sizeof(*initiator_info), FALSE,
-                     motif_drag_initiator_info, 
-                     &type, &format, &nitems, &bytes_after,
-                     (guchar **)&initiator_info);
-
-  if ((format != 8) || (nitems != sizeof (MotifDragInitiatorInfo)) || (bytes_after != 0))
-    {
-      g_warning ("Error reading initiator info\n");
-      return FALSE;
-    }
-
-  motif_read_target_table ();
-
-  initiator_info->targets_index = 
-    card16_to_host (initiator_info->targets_index, initiator_info->byte_order);
-  initiator_info->selection_atom = 
-    card32_to_host (initiator_info->selection_atom, initiator_info->byte_order);
-  
-  if (initiator_info->targets_index >= motif_n_target_lists)
-    {
-      g_warning ("Invalid target index in TOP_LEVEL_ENTER MESSAGE");
-      XFree (initiator_info);
-      return GDK_FILTER_REMOVE;
-    }
-
-  tmp_list = g_list_last (motif_target_lists[initiator_info->targets_index]);
-
-  *targets = NULL;
-  while (tmp_list)
-    {
-      *targets = g_list_prepend (*targets,
-                                tmp_list->data);
-      tmp_list = tmp_list->prev;
-    }
-
-#ifdef G_ENABLE_DEBUG
-  if (gdk_debug_flags & GDK_DEBUG_DND)
-    print_target_list (*targets);
-#endif /* G_ENABLE_DEBUG */
-
-  *selection = initiator_info->selection_atom;
-
-  XFree (initiator_info);
-
-  return TRUE;
-}
-
-static GdkDragContext *
-motif_drag_context_new (GdkWindow *dest_window,
-                       guint32    timestamp,
-                       guint32    source_window,
-                       guint32    atom)
-{
-  GdkDragContext *new_context;
-  GdkDragContextPrivate *private;
-
-  /* FIXME, current_dest_drag really shouldn't be NULL'd
-   * if we error below.
-   */
-  if (current_dest_drag != NULL)
-    {
-      if (timestamp >= current_dest_drag->start_time)
-       {
-         gdk_drag_context_unref (current_dest_drag);
-         current_dest_drag = NULL;
-       }
-      else
-       return NULL;
-    }
-
-  new_context = gdk_drag_context_new ();
-  private = (GdkDragContextPrivate *)new_context;
-
-  new_context->protocol = GDK_DRAG_PROTO_MOTIF;
-  new_context->is_source = FALSE;
-
-  new_context->source_window = gdk_window_lookup (source_window);
-  if (new_context->source_window)
-    gdk_window_ref (new_context->source_window);
-  else
-    {
-      new_context->source_window = gdk_window_foreign_new (source_window);
-      if (!new_context->source_window)
-       {
-         gdk_drag_context_unref (new_context);
-         return NULL;
-       }
-    }
-
-  new_context->dest_window = dest_window;
-  gdk_window_ref (dest_window);
-  new_context->start_time = timestamp;
-
-  if (!motif_read_initiator_info(source_window,
-                                atom,
-                                &new_context->targets,
-                                &private->motif_selection))
-    {
-      gdk_drag_context_unref (new_context);
-      return NULL;
-    }
-
-  return new_context;
-}
-
-/*
- * The MOTIF drag protocol has no real provisions for distinguishing
- * multiple simultaneous drops. If the sources grab the pointer
- * when doing drags, that shouldn't happen, in any case. If it
- * does, we can't do much except hope for the best.
- */
-
-static GdkFilterReturn
-motif_top_level_enter (GdkEvent *event,
-                      guint16   flags, 
-                      guint32   timestamp, 
-                      guint32   source_window, 
-                      guint32   atom)
-{
-  GdkDragContext *new_context;
-
-  GDK_NOTE(DND, g_message ("Motif DND top level enter: flags: %#4x time: %d source_widow: %#4x atom: %d",
-                          flags, timestamp, source_window, atom));
-
-  new_context = motif_drag_context_new (event->any.window, timestamp, source_window, atom);
-  if (!new_context)
-    return GDK_FILTER_REMOVE;
-
-  event->dnd.type = GDK_DRAG_ENTER;
-  event->dnd.context = new_context;
-  gdk_drag_context_ref (new_context);
-
-  current_dest_drag = new_context;
-
-  return GDK_FILTER_TRANSLATE;
-}
-
-GdkFilterReturn
-motif_top_level_leave (GdkEvent *event,
-                      guint16   flags, 
-                      guint32   timestamp)
-{
-  GDK_NOTE(DND, g_message ("Motif DND top level leave: flags: %#4x time: %d",
-                          flags, timestamp));
-
-  if ((current_dest_drag != NULL) &&
-      (current_dest_drag->protocol == GDK_DRAG_PROTO_MOTIF) &&
-      (timestamp >= current_dest_drag->start_time))
-    {
-      event->dnd.type = GDK_DRAG_LEAVE;
-      /* Pass ownership of context to the event */
-      event->dnd.context = current_dest_drag;
-
-      current_dest_drag = NULL;
-
-      return GDK_FILTER_TRANSLATE;
-    }
-  else
-    return GDK_FILTER_REMOVE;
-}
-
-GdkFilterReturn
-motif_motion (GdkEvent *event,
-             guint16   flags, 
-             guint32   timestamp,
-             gint16    x_root,
-             gint16    y_root)
-{
-  GdkDragContextPrivate *private;
-
-  GDK_NOTE(DND, g_message ("Motif DND motion: flags: %#4x time: %d (%d, %d)",
-                          flags, timestamp, x_root, y_root));
-
-  if ((current_dest_drag != NULL) &&
-      (current_dest_drag->protocol == GDK_DRAG_PROTO_MOTIF) &&
-      (timestamp >= current_dest_drag->start_time))
-    {
-      private = (GdkDragContextPrivate *)current_dest_drag;
-
-      event->dnd.type = GDK_DRAG_MOTION;
-      event->dnd.context = current_dest_drag;
-      gdk_drag_context_ref (current_dest_drag);
-
-      event->dnd.time = timestamp;
-
-      motif_dnd_translate_flags (current_dest_drag, flags);
-
-      event->dnd.x_root = x_root;
-      event->dnd.y_root = y_root;
-
-      private->last_x = x_root;
-      private->last_y = y_root;
-
-      private->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
-
-      return GDK_FILTER_TRANSLATE;
-    }
-
-  return GDK_FILTER_REMOVE;
-}
-
-GdkFilterReturn
-motif_operation_changed (GdkEvent *event,
-                        guint16   flags, 
-                        guint32   timestamp)
-{
-  GdkDragContextPrivate *private;
-
-  GDK_NOTE(DND, g_message ("Motif DND operation changed: flags: %#4x time: %d",
-                          flags, timestamp));
-
-  if ((current_dest_drag != NULL) &&
-      (current_dest_drag->protocol == GDK_DRAG_PROTO_MOTIF) &&
-      (timestamp >= current_dest_drag->start_time))
-    {
-      event->dnd.type = GDK_DRAG_MOTION;
-      event->dnd.send_event = FALSE;
-      event->dnd.context = current_dest_drag;
-      gdk_drag_context_ref (current_dest_drag);
-
-      event->dnd.time = timestamp;
-      private = (GdkDragContextPrivate *)current_dest_drag;
-
-      motif_dnd_translate_flags (current_dest_drag, flags);
-
-      event->dnd.x_root = private->last_x;
-      event->dnd.y_root = private->last_y;
-
-      private->drag_status = GDK_DRAG_STATUS_ACTION_WAIT;
-
-      return GDK_FILTER_TRANSLATE;
-    }
-
-  return GDK_FILTER_REMOVE;
-}
-
-GdkFilterReturn
-motif_drop_start (GdkEvent *event,
-                 guint16   flags,
-                 guint32   timestamp,
-                 guint32   source_window,
-                 guint32   atom,
-                 gint16    x_root,
-                 gint16    y_root)
-{
-  GdkDragContext *new_context;
-
-
-  GDK_NOTE(DND, g_message ("Motif DND drop start: flags: %#4x time: %d (%d, %d) source_widow: %#4x atom: %d",
-                          flags, timestamp, x_root, y_root, source_window, atom));
-
-  new_context = motif_drag_context_new (event->any.window, timestamp, source_window, atom);
-  if (!new_context)
-    return GDK_FILTER_REMOVE;
-
-  motif_dnd_translate_flags (new_context, flags);
-
-  event->dnd.type = GDK_DROP_START;
-  event->dnd.context = new_context;
-  event->dnd.time = timestamp;
-  event->dnd.x_root = x_root;
-  event->dnd.y_root = y_root;
-
-  gdk_drag_context_ref (new_context);
-  current_dest_drag = new_context;
-
-  return GDK_FILTER_TRANSLATE;
-}  
-
-GdkFilterReturn
-motif_drag_status (GdkEvent *event,
-                  guint16   flags,
-                  guint32   timestamp)
-{
-  GdkDragContext *context;
-  
-  GDK_NOTE (DND, 
-           g_message ("Motif status message: flags %x", flags));
-
-  context = gdk_drag_context_find (TRUE, 
-                                  GDK_WINDOW_XWINDOW (event->any.window), 
-                                  None);
-
-  if (context)
-    {
-      GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-      if ((private->drag_status == GDK_DRAG_STATUS_MOTION_WAIT) ||
-         (private->drag_status == GDK_DRAG_STATUS_ACTION_WAIT))
-       private->drag_status = GDK_DRAG_STATUS_DRAG;
-      
-      event->dnd.type = GDK_DRAG_STATUS;
-      event->dnd.send_event = FALSE;
-      event->dnd.context = context;
-      gdk_drag_context_ref (context);
-
-      event->dnd.time = timestamp;
-
-      if ((flags & 0x00f0) >> 4 == XmDROP_SITE_VALID)
-       {
-         switch (flags & 0x000f)
-           {
-           case XmDROP_NOOP:
-             context->action = 0;
-             break;
-           case XmDROP_MOVE:
-               context->action = GDK_ACTION_MOVE;
-               break;
-           case XmDROP_COPY:
-             context->action = GDK_ACTION_COPY;
-             break;
-           case XmDROP_LINK:
-             context->action = GDK_ACTION_LINK;
-             break;
-           }
-       }
-      else
-       context->action = 0;
-
-      return GDK_FILTER_TRANSLATE;
-    }
-  return GDK_FILTER_REMOVE;
-}
-
-GdkFilterReturn
-motif_dnd_filter (GdkXEvent *xev,
-                 GdkEvent  *event,
-                 gpointer data)
-{
-  XEvent *xevent = (XEvent *)xev;
-
-  guint8 reason;
-  guint16 flags;
-  guint32 timestamp;
-  guint32 source_window;
-  GdkAtom atom;
-  gint16 x_root, y_root;
-  gboolean is_reply;
-  
-  /* First read some fields common to all Motif DND messages */
-
-  reason = MOTIF_UNPACK_BYTE (xevent, 0);
-  flags = MOTIF_UNPACK_SHORT (xevent, 1);
-  timestamp = MOTIF_UNPACK_LONG (xevent, 1);
-
-  is_reply = ((reason & 0x80) != 0);
-
-  switch (reason & 0x7f)
-    {
-    case XmTOP_LEVEL_ENTER:
-      source_window = MOTIF_UNPACK_LONG (xevent, 2);
-      atom = MOTIF_UNPACK_LONG (xevent, 3);
-      return motif_top_level_enter (event, flags, timestamp, source_window, atom);
-    case XmTOP_LEVEL_LEAVE:
-      return motif_top_level_leave (event, flags, timestamp);
-
-    case XmDRAG_MOTION:
-      x_root = MOTIF_UNPACK_SHORT (xevent, 4);
-      y_root = MOTIF_UNPACK_SHORT (xevent, 5);
-      
-      if (!is_reply)
-       return motif_motion (event, flags, timestamp, x_root, y_root);
-      else
-       return motif_drag_status (event, flags, timestamp);
-
-    case XmDROP_SITE_ENTER:
-      return motif_drag_status (event, flags, timestamp);
-
-    case XmDROP_SITE_LEAVE:
-      return motif_drag_status (event,
-                               XmNO_DROP_SITE << 8 | XmDROP_NOOP, 
-                               timestamp);
-    case XmDROP_START:
-      x_root = MOTIF_UNPACK_SHORT (xevent, 4);
-      y_root = MOTIF_UNPACK_SHORT (xevent, 5);
-      atom = MOTIF_UNPACK_LONG (xevent, 3);
-      source_window = MOTIF_UNPACK_LONG (xevent, 4);
-
-      if (!is_reply)
-       return motif_drop_start (event, flags, timestamp, source_window, atom, x_root, y_root);
-      
-     break;
-    case XmOPERATION_CHANGED:
-      if (!is_reply)
-       return motif_operation_changed (event, flags, timestamp);
-      else
-       return motif_drag_status (event, flags, timestamp);
-
-      break;
-      /* To the best of my knowledge, these next two messages are 
-       * not part of the protocol, though they are defined in
-       * the header files.
-       */
-    case XmDROP_FINISH:
-    case XmDRAG_DROP_FINISH:
-      break;
-    }
-
-  return GDK_FILTER_REMOVE;
-}
-
-/*************************************************************
- ***************************** XDND **************************
- *************************************************************/
-
-/* Utility functions */
-
-static struct {
-  gchar *name;
-  GdkAtom atom;
-  GdkDragAction action;
-} xdnd_actions_table[] = {
-    { "XdndActionCopy",    GDK_NONE, GDK_ACTION_COPY },
-    { "XdndActionMove",    GDK_NONE, GDK_ACTION_MOVE },
-    { "XdndActionLink",    GDK_NONE, GDK_ACTION_LINK },
-    { "XdndActionAsk",     GDK_NONE, GDK_ACTION_ASK  },
-    { "XdndActionPrivate", GDK_NONE, GDK_ACTION_COPY },
-  };
-
-static const gint xdnd_n_actions = sizeof(xdnd_actions_table) / sizeof(xdnd_actions_table[0]);
-static gboolean xdnd_actions_initialized = FALSE;
-
-static void
-xdnd_initialize_actions (void)
-{
-  gint i;
-  
-  xdnd_actions_initialized = TRUE;
-  for (i=0; i < xdnd_n_actions; i++)
-    xdnd_actions_table[i].atom = gdk_atom_intern (xdnd_actions_table[i].name, FALSE);
-}
-
-static GdkDragAction
-xdnd_action_from_atom (GdkAtom atom)
-{
-  gint i;
-
-  if (!xdnd_actions_initialized)
-    xdnd_initialize_actions();
-
-  for (i=0; i<xdnd_n_actions; i++)
-    if (atom == xdnd_actions_table[i].atom)
-      return xdnd_actions_table[i].action;
-
-  return 0;
-}
-
-static GdkAtom
-xdnd_action_to_atom (GdkDragAction action)
-{
-  gint i;
-
-  if (!xdnd_actions_initialized)
-    xdnd_initialize_actions();
-
-  for (i=0; i<xdnd_n_actions; i++)
-    if (action == xdnd_actions_table[i].action)
-      return xdnd_actions_table[i].atom;
-
-  return GDK_NONE;
-}
-
-static GdkAtom xdnd_aware_atom = GDK_NONE;
-
-/* Source side */
-
-static GdkFilterReturn 
-xdnd_status_filter (GdkXEvent *xev,
-                   GdkEvent  *event,
-                   gpointer   data)
-{
-  XEvent *xevent = (XEvent *)xev;
-  guint32 dest_window = xevent->xclient.data.l[0];
-  guint32 flags = xevent->xclient.data.l[1];
-  GdkAtom action = xevent->xclient.data.l[4];
-  GdkDragContext *context;
-  
-  GDK_NOTE (DND, 
-           g_message ("XdndStatus: dest_window: %#x  action: %ld",
-                      dest_window, action));
-
-  
-  context = gdk_drag_context_find (TRUE, xevent->xclient.window, dest_window);
-  if (context)
-    {
-      GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-      if (private->drag_status == GDK_DRAG_STATUS_MOTION_WAIT)
-       private->drag_status = GDK_DRAG_STATUS_DRAG;
-      
-      event->dnd.send_event = FALSE;
-      event->dnd.type = GDK_DRAG_STATUS;
-      event->dnd.context = context;
-      gdk_drag_context_ref (context);
-
-      event->dnd.time = GDK_CURRENT_TIME; /* FIXME? */
-      if (!(action != 0) != !(flags & 1))
-       {
-         GDK_NOTE (DND,
-                   g_warning ("Received status event with flags not corresponding to action!\n"));
-         action = 0;
-       }
-
-      context->action = xdnd_action_from_atom (action);
-
-      return GDK_FILTER_TRANSLATE;
-    }
-
-  return GDK_FILTER_REMOVE;
-}
-
-static GdkFilterReturn 
-xdnd_finished_filter (GdkXEvent *xev,
-                     GdkEvent  *event,
-                     gpointer   data)
-{
-  XEvent *xevent = (XEvent *)xev;
-  guint32 dest_window = xevent->xclient.data.l[0];
-  GdkDragContext *context;
-  
-  GDK_NOTE (DND, 
-           g_message ("XdndFinished: dest_window: %#x", dest_window));
-
-  context = gdk_drag_context_find (TRUE, xevent->xclient.window, dest_window);
-  if (context)
-    {
-      event->dnd.type = GDK_DROP_FINISHED;
-      event->dnd.context = context;
-      gdk_drag_context_ref (context);
-
-      return GDK_FILTER_TRANSLATE;
-    }
-
-  return GDK_FILTER_REMOVE;
-}
-
-static void
-xdnd_set_targets (GdkDragContext *context)
-{
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-  GdkAtom *atomlist;
-  GList *tmp_list = context->targets;
-  gint i;
-  gint n_atoms = g_list_length (context->targets);
-
-  atomlist = g_new (GdkAtom, n_atoms);
-  i = 0;
-  while (tmp_list)
-    {
-      atomlist[i] = GPOINTER_TO_INT (tmp_list->data);
-      tmp_list = tmp_list->next;
-      i++;
-    }
-
-  XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
-                  GDK_WINDOW_XWINDOW (context->source_window),
-                  gdk_atom_intern ("XdndTypeList", FALSE),
-                  XA_ATOM, 32, PropModeReplace,
-                  (guchar *)atomlist, n_atoms);
-
-  g_free (atomlist);
-
-  private->xdnd_targets_set = 1;
-}
-
-static void
-xdnd_set_actions (GdkDragContext *context)
-{
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-  GdkAtom *atomlist;
-  gint i;
-  gint n_atoms;
-  guint actions;
-
-  if (!xdnd_actions_initialized)
-    xdnd_initialize_actions();
-  
-  actions = context->actions;
-  n_atoms = 0;
-  for (i=0; i<xdnd_n_actions; i++)
-    {
-      if (actions & xdnd_actions_table[i].action)
-       {
-         actions &= ~xdnd_actions_table[i].action;
-         n_atoms++;
-       }
-    }
-
-  atomlist = g_new (GdkAtom, n_atoms);
-
-  actions = context->actions;
-  n_atoms = 0;
-  for (i=0; i<xdnd_n_actions; i++)
-    {
-      if (actions & xdnd_actions_table[i].action)
-       {
-         actions &= ~xdnd_actions_table[i].action;
-         atomlist[n_atoms] = xdnd_actions_table[i].atom;
-         n_atoms++;
-       }
-    }
-
-  XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
-                  GDK_WINDOW_XWINDOW (context->source_window),
-                  gdk_atom_intern ("XdndActionList", FALSE),
-                  XA_ATOM, 32, PropModeReplace,
-                  (guchar *)atomlist, n_atoms);
-
-  g_free (atomlist);
-
-  private->xdnd_actions_set = 1;
-  private->xdnd_actions = context->actions;
-}
-
-/*************************************************************
- * xdnd_send_xevent:
- *     Like gdk_send_event, but if the target is the root
- *     window, sets an event mask of ButtonPressMask, otherwise
- *     an event mask of 0.
- *   arguments:
- *     
- *   results:
- *************************************************************/
-
-gint
-xdnd_send_xevent (Window window, gboolean propagate, 
-                 XEvent *event_send)
-{
-  if (window == gdk_root_window)
-    return gdk_send_xevent (window, propagate, ButtonPressMask, event_send);
-  else
-    return gdk_send_xevent (window, propagate, 0, event_send);
-}
-
-static void
-xdnd_send_enter (GdkDragContext *context)
-{
-  XEvent xev;
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-
-  xev.xclient.type = ClientMessage;
-  xev.xclient.message_type = gdk_atom_intern ("XdndEnter", FALSE);
-  xev.xclient.format = 32;
-  xev.xclient.window = private->drop_xid ? 
-                           private->drop_xid : 
-                           GDK_WINDOW_XWINDOW (context->dest_window);
-  xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
-  xev.xclient.data.l[1] = (3 << 24); /* version */
-  xev.xclient.data.l[2] = 0;
-  xev.xclient.data.l[3] = 0;
-  xev.xclient.data.l[4] = 0;
-
-  if (!private->xdnd_selection)
-    private->xdnd_selection = gdk_atom_intern ("XdndSelection", FALSE);
-
-  if (g_list_length (context->targets) > 3)
-    {
-      if (!private->xdnd_targets_set)
-       xdnd_set_targets (context);
-      xev.xclient.data.l[1] |= 1;
-    }
-  else
-    {
-      GList *tmp_list = context->targets;
-      gint i = 2;
-
-      while (tmp_list)
-       {
-         xev.xclient.data.l[i] = GPOINTER_TO_INT (tmp_list->data);
-         tmp_list = tmp_list->next;
-         i++;
-       }
-    }
-
-  if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
-                        FALSE, &xev))
-    {
-      GDK_NOTE (DND, 
-               g_message ("Send event to %lx failed",
-                          GDK_WINDOW_XWINDOW (context->dest_window)));
-      gdk_window_unref (context->dest_window);
-      context->dest_window = NULL;
-    }
-}
-
-static void
-xdnd_send_leave (GdkDragContext *context)
-{
-  XEvent xev;
-
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-
-  xev.xclient.type = ClientMessage;
-  xev.xclient.message_type = gdk_atom_intern ("XdndLeave", FALSE);
-  xev.xclient.format = 32;
-  xev.xclient.window = private->drop_xid ? 
-                           private->drop_xid : 
-                           GDK_WINDOW_XWINDOW (context->dest_window);
-  xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
-  xev.xclient.data.l[1] = 0;
-  xev.xclient.data.l[2] = 0;
-  xev.xclient.data.l[3] = 0;
-  xev.xclient.data.l[4] = 0;
-
-  if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
-                        FALSE, &xev))
-    {
-      GDK_NOTE (DND, 
-               g_message ("Send event to %lx failed",
-                          GDK_WINDOW_XWINDOW (context->dest_window)));
-      gdk_window_unref (context->dest_window);
-      context->dest_window = NULL;
-    }
-}
-
-static void
-xdnd_send_drop (GdkDragContext *context, guint32 time)
-{
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-  XEvent xev;
-
-  xev.xclient.type = ClientMessage;
-  xev.xclient.message_type = gdk_atom_intern ("XdndDrop", FALSE);
-  xev.xclient.format = 32;
-  xev.xclient.window = private->drop_xid ? 
-                           private->drop_xid : 
-                           GDK_WINDOW_XWINDOW (context->dest_window);
-  xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
-  xev.xclient.data.l[1] = 0;
-  xev.xclient.data.l[2] = time;
-  xev.xclient.data.l[3] = 0;
-  xev.xclient.data.l[4] = 0;
-
-  if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
-                        FALSE, &xev))
-    {
-      GDK_NOTE (DND, 
-               g_message ("Send event to %lx failed",
-                          GDK_WINDOW_XWINDOW (context->dest_window)));
-      gdk_window_unref (context->dest_window);
-      context->dest_window = NULL;
-    }
-}
-
-static void
-xdnd_send_motion (GdkDragContext *context,
-                 gint            x_root, 
-                 gint            y_root,
-                 GdkDragAction   action,
-                 guint32         time)
-{
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-  XEvent xev;
-
-  xev.xclient.type = ClientMessage;
-  xev.xclient.message_type = gdk_atom_intern ("XdndPosition", FALSE);
-  xev.xclient.format = 32;
-  xev.xclient.window = private->drop_xid ? 
-                           private->drop_xid : 
-                           GDK_WINDOW_XWINDOW (context->dest_window);
-  xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
-  xev.xclient.data.l[1] = 0;
-  xev.xclient.data.l[2] = (x_root << 16) | y_root;
-  xev.xclient.data.l[3] = time;
-  xev.xclient.data.l[4] = xdnd_action_to_atom (action);
-
-  if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
-                        FALSE, &xev))
-    {
-      GDK_NOTE (DND, 
-               g_message ("Send event to %lx failed",
-                          GDK_WINDOW_XWINDOW (context->dest_window)));
-      gdk_window_unref (context->dest_window);
-      context->dest_window = NULL;
-    }
-  private->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
-}
-
-static guint32
-xdnd_check_dest (Window win)
-{
-  gboolean retval = FALSE;
-  Atom type = None;
-  int format;
-  unsigned long nitems, after;
-  GdkAtom *version;
-  Window *proxy_data;
-  Window proxy;
-  static GdkAtom xdnd_proxy_atom = GDK_NONE;
-
-  gint old_warnings = gdk_error_warnings;
-
-  if (!xdnd_proxy_atom)
-    xdnd_proxy_atom = gdk_atom_intern ("XdndProxy", FALSE);
-
-  if (!xdnd_aware_atom)
-    xdnd_aware_atom = gdk_atom_intern ("XdndAware", FALSE);
-
-  proxy = GDK_NONE;
-  
-  gdk_error_code = 0;
-  gdk_error_warnings = 0;
-
-  XGetWindowProperty (gdk_display, win, 
-                     xdnd_proxy_atom, 0, 
-                     1, False, AnyPropertyType,
-                     &type, &format, &nitems, &after, 
-                     (guchar **)&proxy_data);
-
-  if (!gdk_error_code)
-    {
-      if (type != None)
-       {
-         if ((format == 32) && (nitems == 1))
-           {
-             proxy = *proxy_data;
-           }
-         else
-           GDK_NOTE (DND, 
-                     g_warning ("Invalid XdndOwner property on window %ld\n", win));
-         
-         XFree (proxy_data);
-       }
-      
-      XGetWindowProperty (gdk_display, proxy ? proxy : win,
-                         xdnd_aware_atom, 0, 
-                         1, False, AnyPropertyType,
-                         &type, &format, &nitems, &after, 
-                         (guchar **)&version);
-      
-      if (!gdk_error_code && type != None)
-       {
-         if ((format == 32) && (nitems == 1))
-           {
-             if (*version == 3)
-               retval = TRUE;
-           }
-         else
-           GDK_NOTE (DND, 
-                     g_warning ("Invalid XdndAware property on window %ld\n", win));
-         
-         XFree (version);
-       }
-      
-    }
-
-  gdk_error_warnings = old_warnings;
-  gdk_error_code = 0;
-  
-  return retval ? (proxy ? proxy : win) : GDK_NONE;
-}
-
-/* Target side */
-
-static void
-xdnd_read_actions (GdkDragContext *context)
-{
-  Atom type;
-  int format;
-  gulong nitems, after;
-  Atom *data;
-
-  gint i;
-
-  gint old_warnings = gdk_error_warnings;
-
-  gdk_error_code = 0;
-  gdk_error_warnings = 0;
-
-  /* Get the XdndActionList, if set */
-
-  XGetWindowProperty (GDK_WINDOW_XDISPLAY (context->source_window),
-                     GDK_WINDOW_XWINDOW (context->source_window),
-                     gdk_atom_intern ("XdndActionList", FALSE), 0, 65536,
-                     False, XA_ATOM, &type, &format, &nitems,
-                     &after, (guchar **)&data);
-  
-  if (!gdk_error_code && (format == 32) && (type == XA_ATOM))
-    {
-      context->actions = 0;
-
-      for (i=0; i<nitems; i++)
-       context->actions |= xdnd_action_from_atom (data[i]);
-
-      ((GdkDragContextPrivate *)context)->xdnd_have_actions = TRUE;
-
-#ifdef G_ENABLE_DEBUG
-      if (gdk_debug_flags & GDK_DEBUG_DND)
-       {
-         GString *action_str = g_string_new (NULL);
-         if (context->actions & GDK_ACTION_MOVE)
-           g_string_append(action_str, "MOVE ");
-         if (context->actions & GDK_ACTION_COPY)
-           g_string_append(action_str, "COPY ");
-         if (context->actions & GDK_ACTION_LINK)
-           g_string_append(action_str, "LINK ");
-         if (context->actions & GDK_ACTION_ASK)
-           g_string_append(action_str, "ASK ");
-         
-         g_message("Xdnd actions = %s", action_str->str);
-         g_string_free (action_str, TRUE);
-       }
-#endif /* G_ENABLE_DEBUG */
-
-      XFree(data);
-    }
-
-  gdk_error_warnings = old_warnings;
-  gdk_error_code = 0;
-}
-
-/* We have to make sure that the XdndActionList we keep internally
- * is up to date with the XdndActionList on the source window
- * because we get no notification, because Xdnd wasn't meant
- * to continually send actions. So we select on PropertyChangeMask
- * and add this filter.
- */
-static GdkFilterReturn 
-xdnd_source_window_filter (GdkXEvent *xev,
-                          GdkEvent  *event,
-                          gpointer   cb_data)
-{
-  XEvent *xevent = (XEvent *)xev;
-  GdkDragContext *context = cb_data;
-
-  if ((xevent->xany.type == PropertyNotify) &&
-      (xevent->xproperty.atom == gdk_atom_intern ("XdndActionList", FALSE)))
-    {
-      xdnd_read_actions (context);
-
-      return GDK_FILTER_REMOVE;
-    }
-
-  return GDK_FILTER_CONTINUE;
-}
-
-static void
-xdnd_manage_source_filter (GdkDragContext *context,
-                          GdkWindow      *window,
-                          gboolean        add_filter)
-{
-  gint old_warnings = 0;       /* quiet gcc */
-                              
-  gboolean is_foreign = GDK_DRAWABLE_TYPE (window);
-
-  if (is_foreign)
-    {
-      old_warnings = gdk_error_warnings;
-      gdk_error_warnings = 0;
-    }
-
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      if (add_filter)
-       {
-         gdk_window_set_events (window,
-                                gdk_window_get_events (window) |
-                                GDK_PROPERTY_CHANGE_MASK);
-         gdk_window_add_filter (window, xdnd_source_window_filter, context);
-
-       }
-      else
-       {
-         gdk_window_remove_filter (window,
-                                   xdnd_source_window_filter,
-                                   context);
-         /* Should we remove the GDK_PROPERTY_NOTIFY mask?
-          * but we might want it for other reasons. (Like
-          * INCR selection transactions).
-          */
-       }
-    }
-
-  if (is_foreign)
-    {
-      gdk_flush();
-      gdk_error_warnings = old_warnings;
-    }
-}
-
-static GdkFilterReturn 
-xdnd_enter_filter (GdkXEvent *xev,
-                  GdkEvent  *event,
-                  gpointer   cb_data)
-{
-  XEvent *xevent = (XEvent *)xev;
-  GdkDragContext *new_context;
-  gint i;
-  
-  Atom type;
-  int format;
-  gulong nitems, after;
-  Atom *data;
-
-  guint32 source_window = xevent->xclient.data.l[0];
-  gboolean get_types = ((xevent->xclient.data.l[1] & 1) != 0);
-  gint version = (xevent->xclient.data.l[1] & 0xff000000) >> 24;
-  
-  GDK_NOTE (DND, 
-           g_message ("XdndEnter: source_window: %#x, version: %#x",
-                      source_window, version));
-
-  if (version != 3)
-    {
-      /* Old source ignore */
-      GDK_NOTE (DND, g_message ("Ignored old XdndEnter message"));
-      return GDK_FILTER_REMOVE;
-    }
-  
-  if (current_dest_drag != NULL)
-    {
-      gdk_drag_context_unref (current_dest_drag);
-      current_dest_drag = NULL;
-    }
-
-  new_context = gdk_drag_context_new ();
-  new_context->protocol = GDK_DRAG_PROTO_XDND;
-  new_context->is_source = FALSE;
-
-  new_context->source_window = gdk_window_lookup (source_window);
-  if (new_context->source_window)
-    gdk_window_ref (new_context->source_window);
-  else
-    {
-      new_context->source_window = gdk_window_foreign_new (source_window);
-      if (!new_context->source_window)
-       {
-         gdk_drag_context_unref (new_context);
-         return GDK_FILTER_REMOVE;
-       }
-    }
-  new_context->dest_window = event->any.window;
-  gdk_window_ref (new_context->dest_window);
-
-  new_context->targets = NULL;
-  if (get_types)
-    {
-      XGetWindowProperty (GDK_WINDOW_XDISPLAY (event->any.window), 
-                         source_window, 
-                         gdk_atom_intern ("XdndTypeList", FALSE), 0, 65536,
-                         False, XA_ATOM, &type, &format, &nitems,
-                         &after, (guchar **)&data);
-
-      if ((format != 32) || (type != XA_ATOM))
-       {
-         gdk_drag_context_unref (new_context);
-         return GDK_FILTER_REMOVE;
-       }
-
-      for (i=0; i<nitems; i++)
-       new_context->targets = g_list_append (new_context->targets,
-                                             GUINT_TO_POINTER (data[i]));
-
-      XFree(data);
-    }
-  else
-    {
-      for (i=0; i<3; i++)
-       if (xevent->xclient.data.l[2+i])
-         new_context->targets = g_list_append (new_context->targets,
-                                               GUINT_TO_POINTER (xevent->xclient.data.l[2+i]));
-    }
-
-#ifdef G_ENABLE_DEBUG
-  if (gdk_debug_flags & GDK_DEBUG_DND)
-    print_target_list (new_context->targets);
-#endif /* G_ENABLE_DEBUG */
-
-  xdnd_manage_source_filter (new_context, new_context->source_window, TRUE);
-  xdnd_read_actions (new_context);
-
-  event->dnd.type = GDK_DRAG_ENTER;
-  event->dnd.context = new_context;
-  gdk_drag_context_ref (new_context);
-
-  current_dest_drag = new_context;
-  ((GdkDragContextPrivate *)new_context)->xdnd_selection = 
-    gdk_atom_intern ("XdndSelection", FALSE);
-
-  return GDK_FILTER_TRANSLATE;
-}
-
-static GdkFilterReturn 
-xdnd_leave_filter (GdkXEvent *xev,
-                  GdkEvent  *event,
-                  gpointer   data)
-{
-  XEvent *xevent = (XEvent *)xev;
-  guint32 source_window = xevent->xclient.data.l[0];
-  
-  GDK_NOTE (DND, 
-           g_message ("XdndLeave: source_window: %#x",
-                      source_window));
-
-  if ((current_dest_drag != NULL) &&
-      (current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
-      (GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
-    {
-      event->dnd.type = GDK_DRAG_LEAVE;
-      /* Pass ownership of context to the event */
-      event->dnd.context = current_dest_drag;
-
-      current_dest_drag = NULL;
-
-      return GDK_FILTER_TRANSLATE;
-    }
-  else
-    return GDK_FILTER_REMOVE;
-}
-
-static GdkFilterReturn 
-xdnd_position_filter (GdkXEvent *xev,
-                     GdkEvent  *event,
-                     gpointer   data)
-{
-  XEvent *xevent = (XEvent *)xev;
-  guint32 source_window = xevent->xclient.data.l[0];
-  gint16 x_root = xevent->xclient.data.l[2] >> 16;
-  gint16 y_root = xevent->xclient.data.l[2] & 0xffff;
-  guint32 time = xevent->xclient.data.l[3];
-  GdkAtom action = xevent->xclient.data.l[4];
-  
-  GDK_NOTE (DND, 
-           g_message ("XdndPosition: source_window: %#x  position: (%d, %d)  time: %d  action: %ld",
-                      source_window, x_root, y_root, time, action));
-
-  
-  if ((current_dest_drag != NULL) &&
-      (current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
-      (GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
-    {
-      event->dnd.type = GDK_DRAG_MOTION;
-      event->dnd.context = current_dest_drag;
-      gdk_drag_context_ref (current_dest_drag);
-
-      event->dnd.time = time;
-
-      current_dest_drag->suggested_action = xdnd_action_from_atom (action);
-      if (!((GdkDragContextPrivate *)current_dest_drag)->xdnd_have_actions)
-       current_dest_drag->actions = current_dest_drag->suggested_action;
-
-      event->dnd.x_root = x_root;
-      event->dnd.y_root = y_root;
-
-      ((GdkDragContextPrivate *)current_dest_drag)->last_x = x_root;
-      ((GdkDragContextPrivate *)current_dest_drag)->last_y = y_root;
-      
-      return GDK_FILTER_TRANSLATE;
-    }
-
-  return GDK_FILTER_REMOVE;
-}
-
-static GdkFilterReturn 
-xdnd_drop_filter (GdkXEvent *xev,
-                 GdkEvent  *event,
-                 gpointer   data)
-{
-  XEvent *xevent = (XEvent *)xev;
-  guint32 source_window = xevent->xclient.data.l[0];
-  guint32 time = xevent->xclient.data.l[2];
-  
-  GDK_NOTE (DND, 
-           g_message ("XdndDrop: source_window: %#x  time: %d",
-                      source_window, time));
-
-  if ((current_dest_drag != NULL) &&
-      (current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
-      (GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
-    {
-      GdkDragContextPrivate *private;
-      private = (GdkDragContextPrivate *)current_dest_drag;
-
-      event->dnd.type = GDK_DROP_START;
-
-      event->dnd.context = current_dest_drag;
-      gdk_drag_context_ref (current_dest_drag);
-
-      event->dnd.time = time;
-      event->dnd.x_root = private->last_x;
-      event->dnd.y_root = private->last_y;
-      
-      return GDK_FILTER_TRANSLATE;
-    }
-
-  return GDK_FILTER_REMOVE;
-}
-
-/*************************************************************
- ************************** Public API ***********************
- *************************************************************/
-
-void
-gdk_dnd_init (void)
-{
-  init_byte_order();
-
-  gdk_add_client_message_filter (
-       gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE),
-       motif_dnd_filter, NULL);
-  gdk_add_client_message_filter (
-       gdk_atom_intern ("XdndEnter", FALSE),
-       xdnd_enter_filter, NULL);
-  gdk_add_client_message_filter (
-       gdk_atom_intern ("XdndLeave", FALSE),
-       xdnd_leave_filter, NULL);
-  gdk_add_client_message_filter (
-       gdk_atom_intern ("XdndPosition", FALSE),
-       xdnd_position_filter, NULL);
-  gdk_add_client_message_filter (
-       gdk_atom_intern ("XdndStatus", FALSE),
-       xdnd_status_filter, NULL);
-  gdk_add_client_message_filter (
-       gdk_atom_intern ("XdndFinished", FALSE),
-       xdnd_finished_filter, NULL);
-  gdk_add_client_message_filter (
-       gdk_atom_intern ("XdndDrop", FALSE),
-       xdnd_drop_filter, NULL);
-}                    
-
-/* Source side */
-
-static void
-gdk_drag_do_leave (GdkDragContext *context, guint32 time)
-{
-  if (context->dest_window)
-    {
-      switch (context->protocol)
-       {
-       case GDK_DRAG_PROTO_MOTIF:
-         motif_send_leave (context, time);
-         break;
-       case GDK_DRAG_PROTO_XDND:
-         xdnd_send_leave (context);
-         break;
-       case GDK_DRAG_PROTO_ROOTWIN:
-       case GDK_DRAG_PROTO_NONE:
-         break;
-       }
-
-      gdk_window_unref (context->dest_window);
-      context->dest_window = NULL;
-    }
-}
-
-GdkDragContext * 
-gdk_drag_begin (GdkWindow     *window,
-               GList         *targets)
-{
-  GList *tmp_list;
-  GdkDragContext *new_context;
-  
-  g_return_val_if_fail (window != NULL, NULL);
-
-  new_context = gdk_drag_context_new ();
-  new_context->is_source = TRUE;
-  new_context->source_window = window;
-  gdk_window_ref (window);
-
-  tmp_list = g_list_last (targets);
-  new_context->targets = NULL;
-  while (tmp_list)
-    {
-      new_context->targets = g_list_prepend (new_context->targets,
-                                            tmp_list->data);
-      tmp_list = tmp_list->prev;
-    }
-
-  new_context->actions = 0;
-
-  return new_context;
-}
-
-guint32
-gdk_drag_get_protocol (guint32          xid,
-                      GdkDragProtocol *protocol)
-{
-  guint32 retval;
-  
-  if ((retval = xdnd_check_dest (xid)))
-    {
-      *protocol = GDK_DRAG_PROTO_XDND;
-      GDK_NOTE (DND, g_message ("Entering dnd window %#x\n", xid));
-      return retval;
-    }
-  else if ((retval = motif_check_dest (xid)))
-    {
-      *protocol = GDK_DRAG_PROTO_MOTIF;
-      GDK_NOTE (DND, g_message ("Entering motif window %#x\n", xid));
-      return retval;
-    }
-  else
-    {
-      /* Check if this is a root window */
-
-      gboolean rootwin = FALSE;
-      gint old_warnings = gdk_error_warnings;
-      Atom type = None;
-      int format;
-      unsigned long nitems, after;
-      unsigned char *data;
-
-      if (xid == gdk_root_window)
-       rootwin = TRUE;
-
-      if (!rootwin)
-       {
-         gdk_error_code = 0;
-         
-         XGetWindowProperty (gdk_display, xid,
-                             gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE),
-                             0, 0, False, AnyPropertyType,
-                             &type, &format, &nitems, &after, &data);
-         if ((gdk_error_code == 0) && type != None)
-           {
-             XFree (data);
-             rootwin = TRUE;
-           }
-       }
-
-      /* Until I find out what window manager the next one is for,
-       * I'm leaving it commented out. It's supported in the
-       * xscreensaver sources, though.
-       */
-#if 0
-      if (!rootwin)
-       {
-         gdk_error_code = 0;
-         
-         XGetWindowProperty (gdk_display, win,
-                             gdk_atom_intern ("__SWM_VROOT", FALSE),
-                             0, 0, False, AnyPropertyType,
-                             &type, &format, &nitems, &data);
-         if ((gdk_error_code == 0) && type != None)
-           rootwin = TRUE;
-       }
-#endif      
-
-      gdk_error_warnings = old_warnings;
-
-      if (rootwin)
-       {
-         *protocol = GDK_DRAG_PROTO_ROOTWIN;
-         return xid;
-       }
-    }
-
-  *protocol = GDK_DRAG_PROTO_NONE;
-  return GDK_NONE;
-}
-
-void
-gdk_drag_find_window (GdkDragContext  *context,
-                     GdkWindow       *drag_window,
-                     gint             x_root,
-                     gint             y_root,
-                     GdkWindow      **dest_window,
-                     GdkDragProtocol *protocol)
-{
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-  Window dest;
-
-  g_return_if_fail (context != NULL);
-
-  if (!private->window_cache)
-    private->window_cache = gdk_window_cache_new();
-
-  dest = get_client_window_at_coords (private->window_cache,
-                                     drag_window ? 
-                                     GDK_WINDOW_XWINDOW (drag_window) : GDK_NONE,
-                                     x_root, y_root);
-
-  if (private->dest_xid != dest)
-    {
-      Window recipient;
-      private->dest_xid = dest;
-
-      /* Check if new destination accepts drags, and which protocol */
-
-      /* There is some ugliness here. We actually need to pass
-       * _three_ pieces of information to drag_motion - dest_window,
-       * protocol, and the XID of the unproxied window. The first
-       * two are passed explicitely, the third implicitly through
-       * protocol->dest_xid.
-       */
-      if ((recipient = gdk_drag_get_protocol (dest, protocol)))
-       {
-         *dest_window = gdk_window_lookup (recipient);
-         if (*dest_window)
-           gdk_window_ref (*dest_window);
-         else
-           *dest_window = gdk_window_foreign_new (recipient);
-       }
-      else
-       *dest_window = NULL;
-    }
-  else
-    {
-      *dest_window = context->dest_window;
-      if (*dest_window)
-       gdk_window_ref (*dest_window);
-      *protocol = context->protocol;
-    }
-}
-
-gboolean        
-gdk_drag_motion (GdkDragContext *context,
-                GdkWindow      *dest_window,
-                GdkDragProtocol protocol,
-                gint            x_root, 
-                gint            y_root,
-                GdkDragAction   suggested_action,
-                GdkDragAction   possible_actions,
-                guint32         time)
-{
-  GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
-
-  g_return_val_if_fail (context != NULL, FALSE);
-
-  /* When we have a Xdnd target, make sure our XdndActionList
-   * matches the current actions;
-   */
-  private->old_actions = context->actions;
-  context->actions = possible_actions;
-  
-  if ((protocol == GDK_DRAG_PROTO_XDND) &&
-      (!private->xdnd_actions_set ||
-       private->xdnd_actions != possible_actions))
-    xdnd_set_actions (context);
-
-  if (context->dest_window != dest_window)
-    {
-      GdkEvent temp_event;
-
-      /* Send a leave to the last destination */
-      gdk_drag_do_leave (context, time);
-      private->drag_status = GDK_DRAG_STATUS_DRAG;
-
-      /* Check if new destination accepts drags, and which protocol */
-
-      if (dest_window)
-       {
-         context->dest_window = dest_window;
-         private->drop_xid = private->dest_xid;
-         gdk_window_ref (context->dest_window);
-         context->protocol = protocol;
-
-         switch (protocol)
-           {
-           case GDK_DRAG_PROTO_MOTIF:
-             motif_send_enter (context, time);
-             break;
-
-           case GDK_DRAG_PROTO_XDND:
-             xdnd_send_enter (context);
-             break;
-
-           case GDK_DRAG_PROTO_ROOTWIN:
-           case GDK_DRAG_PROTO_NONE:
-             break;
-           }
-         private->old_action = suggested_action;
-         context->suggested_action = suggested_action;
-         private->old_actions = possible_actions;
-       }
-      else
-       {
-         context->dest_window = NULL;
-         private->drop_xid = None;
-         context->action = 0;
-       }
-
-      /* Push a status event, to let the client know that
-       * the drag changed 
-       */
-
-      temp_event.dnd.type = GDK_DRAG_STATUS;
-      temp_event.dnd.window = context->source_window;
-      /* We use this to signal a synthetic status. Perhaps
-       * we should use an extra field...
-       */
-      temp_event.dnd.send_event = TRUE;
-
-      temp_event.dnd.context = context;
-      temp_event.dnd.time = time;
-
-      gdk_event_put (&temp_event);
-    }
-  else
-    {
-      private->old_action = context->suggested_action;
-      context->suggested_action = suggested_action;
-    }
-
-  /* Send a drag-motion event */
-
-  private->last_x = x_root;
-  private->last_y = y_root;
-      
-  if (context->dest_window)
-    {
-      if (private->drag_status == GDK_DRAG_STATUS_DRAG)
-       {
-         switch (context->protocol)
-           {
-           case GDK_DRAG_PROTO_MOTIF:
-             motif_send_motion (context, x_root, y_root, suggested_action, time);
-             break;
-             
-           case GDK_DRAG_PROTO_XDND:
-             xdnd_send_motion (context, x_root, y_root, suggested_action, time);
-             break;
-
-           case GDK_DRAG_PROTO_ROOTWIN:
-             {
-               GdkEvent temp_event;
-
-               if (g_list_find (context->targets,
-                                GUINT_TO_POINTER (gdk_atom_intern ("application/x-rootwin-drop", FALSE))))
-                 context->action = context->suggested_action;
-               else
-                 context->action = 0;
-
-               temp_event.dnd.type = GDK_DRAG_STATUS;
-               temp_event.dnd.window = context->source_window;
-               temp_event.dnd.send_event = FALSE;
-               temp_event.dnd.context = context;
-               temp_event.dnd.time = time;
-
-               gdk_event_put (&temp_event);
-             }
-             break;
-           case GDK_DRAG_PROTO_NONE:
-             g_warning ("GDK_DRAG_PROTO_NONE is not valid in gdk_drag_motion()");
-             break;
-           }
-       }
-      else
-       return TRUE;
-    }
-
-  return FALSE;
-}
-
-void
-gdk_drag_drop (GdkDragContext *context,
-              guint32         time)
-{
-  g_return_if_fail (context != NULL);
-
-  if (context->dest_window)
-    {
-      switch (context->protocol)
-       {
-       case GDK_DRAG_PROTO_MOTIF:
-         motif_send_leave (context, time);
-         motif_send_drop (context, time);
-         break;
-         
-       case GDK_DRAG_PROTO_XDND:
-         xdnd_send_drop (context, time);
-         break;
-
-       case GDK_DRAG_PROTO_ROOTWIN:
-         g_warning ("Drops for GDK_DRAG_PROTO_ROOTWIN must be handled internally");
-         break;
-       case GDK_DRAG_PROTO_NONE:
-         g_warning ("GDK_DRAG_PROTO_NONE is not valid in gdk_drag_drop()");
-         break;
-       }
-    }
-}
-
-void
-gdk_drag_abort (GdkDragContext *context,
-               guint32         time)
-{
-  g_return_if_fail (context != NULL);
-
-  gdk_drag_do_leave (context, time);
-}
-
-/* Destination side */
-
-void             
-gdk_drag_status (GdkDragContext   *context,
-                GdkDragAction     action,
-                guint32           time)
-{
-  GdkDragContextPrivate *private;
-  XEvent xev;
-
-  g_return_if_fail (context != NULL);
-
-  private = (GdkDragContextPrivate *)context;
-
-  context->action = action;
-  
-  if (context->protocol == GDK_DRAG_PROTO_MOTIF)
-    {
-      xev.xclient.type = ClientMessage;
-      xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
-      xev.xclient.format = 8;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
-
-      if (private->drag_status == GDK_DRAG_STATUS_ACTION_WAIT)
-       {
-         MOTIF_XCLIENT_BYTE (&xev, 0) = XmOPERATION_CHANGED | 0x80;
-       }
-      else
-       {
-         if ((action != 0) != (private->old_action != 0))
-           {
-             if (action != 0)
-               MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_SITE_ENTER | 0x80;
-             else
-               MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_SITE_LEAVE | 0x80;
-           }
-         else
-           MOTIF_XCLIENT_BYTE (&xev, 0) = XmDRAG_MOTION | 0x80;
-       }
-
-      MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
-
-      switch (action)
-       {
-       case GDK_ACTION_MOVE:
-         MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_MOVE;
-         break;
-       case GDK_ACTION_COPY:
-         MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_COPY;
-         break;
-       case GDK_ACTION_LINK:
-         MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_LINK;
-         break;
-       default:
-         MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_NOOP;
-         break;
-       }
-
-      if (action)
-       MOTIF_XCLIENT_SHORT (&xev, 1) |= (XmDROP_SITE_VALID << 4);
-      else
-       MOTIF_XCLIENT_SHORT (&xev, 1) |= (XmNO_DROP_SITE << 4);
-
-      MOTIF_XCLIENT_LONG (&xev, 1) = time;
-      MOTIF_XCLIENT_SHORT (&xev, 4) = private->last_x;
-      MOTIF_XCLIENT_SHORT (&xev, 5) = private->last_y;
-
-      if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
-                      FALSE, 0, &xev))
-       GDK_NOTE (DND, 
-                 g_message ("Send event to %lx failed",
-                            GDK_WINDOW_XWINDOW (context->source_window)));
-    }
-  else if (context->protocol == GDK_DRAG_PROTO_XDND)
-    {
-      xev.xclient.type = ClientMessage;
-      xev.xclient.message_type = gdk_atom_intern ("XdndStatus", FALSE);
-      xev.xclient.format = 32;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
-
-      xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->dest_window);
-      xev.xclient.data.l[1] = (action != 0) ? (2 | 1) : 0;
-      xev.xclient.data.l[2] = 0;
-      xev.xclient.data.l[3] = 0;
-      xev.xclient.data.l[4] = xdnd_action_to_atom (action);
-
-      if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
-                            FALSE, &xev))
-       GDK_NOTE (DND, 
-                 g_message ("Send event to %lx failed",
-                            GDK_WINDOW_XWINDOW (context->source_window)));
-    }
-
-  private->old_action = action;
-}
-
-void 
-gdk_drop_reply (GdkDragContext   *context,
-               gboolean          ok,
-               guint32           time)
-{
-  GdkDragContextPrivate *private;
-
-  g_return_if_fail (context != NULL);
-
-  private = (GdkDragContextPrivate *)context;
-  
-  if (context->protocol == GDK_DRAG_PROTO_MOTIF)
-    {
-      XEvent xev;
-
-      xev.xclient.type = ClientMessage;
-      xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
-      xev.xclient.format = 8;
-
-      MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START | 0x80;
-      MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
-      if (ok)
-       MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_COPY | 
-                                      (XmDROP_SITE_VALID << 4) |
-                                      (XmDROP_NOOP << 8) |
-                                      (XmDROP << 12);
-      else
-       MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_NOOP | 
-                                      (XmNO_DROP_SITE << 4) |
-                                      (XmDROP_NOOP << 8) |
-                                      (XmDROP_CANCEL << 12);
-      MOTIF_XCLIENT_SHORT (&xev, 2) = private->last_x;
-      MOTIF_XCLIENT_SHORT (&xev, 3) = private->last_y;
-      
-      gdk_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
-                      FALSE, 0, &xev);
-    }
-}
-
-void             
-gdk_drop_finish (GdkDragContext   *context,
-                gboolean          success,
-                guint32           time)
-{
-  g_return_if_fail (context != NULL);
-
-  if (context->protocol == GDK_DRAG_PROTO_XDND)
-    {
-      XEvent xev;
-
-      xev.xclient.type = ClientMessage;
-      xev.xclient.message_type = gdk_atom_intern ("XdndFinished", FALSE);
-      xev.xclient.format = 32;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
-
-      xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->dest_window);
-      xev.xclient.data.l[1] = 0;
-      xev.xclient.data.l[2] = 0;
-      xev.xclient.data.l[3] = 0;
-      xev.xclient.data.l[4] = 0;
-
-      if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
-                            FALSE, &xev))
-       GDK_NOTE (DND, 
-                 g_message ("Send event to %lx failed",
-                            GDK_WINDOW_XWINDOW (context->source_window)));
-    }
-}
-
-
-void            
-gdk_window_register_dnd (GdkWindow      *window)
-{
-  static gulong xdnd_version = 3;
-  MotifDragReceiverInfo info;
-
-  g_return_if_fail (window != NULL);
-
-  /* Set Motif drag receiver information property */
-
-  if (!motif_drag_receiver_info_atom)
-    motif_drag_receiver_info_atom = gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE);
-
-  info.byte_order = local_byte_order;
-  info.protocol_version = 0;
-  info.protocol_style = XmDRAG_DYNAMIC;
-  info.proxy_window = GDK_NONE;
-  info.num_drop_sites = 0;
-  info.total_size = sizeof(info);
-
-  XChangeProperty (gdk_display, GDK_WINDOW_XWINDOW (window),
-                  motif_drag_receiver_info_atom,
-                  motif_drag_receiver_info_atom,
-                  8, PropModeReplace,
-                  (guchar *)&info,
-                  sizeof (info));
-
-  /* Set XdndAware */
-
-  if (!xdnd_aware_atom)
-    xdnd_aware_atom = gdk_atom_intern ("XdndAware", FALSE);
-
-  /* The property needs to be of type XA_ATOM, not XA_INTEGER. Blech */
-  XChangeProperty (GDK_WINDOW_XDISPLAY (window), 
-                  GDK_WINDOW_XWINDOW (window),
-                  xdnd_aware_atom, XA_ATOM,
-                  32, PropModeReplace,
-                  (guchar *)&xdnd_version, 1);
-}
-
-/*************************************************************
- * gdk_drag_get_selection:
- *     Returns the selection atom for the current source window
- *   arguments:
- *     
- *   results:
- *************************************************************/
-
-GdkAtom       
-gdk_drag_get_selection (GdkDragContext *context)
-{
-  g_return_val_if_fail (context != NULL, GDK_NONE);
-
-  if (context->protocol == GDK_DRAG_PROTO_MOTIF)
-    return ((GdkDragContextPrivate *)context)->motif_selection;
-  else if (context->protocol == GDK_DRAG_PROTO_XDND)
-    return ((GdkDragContextPrivate *)context)->xdnd_selection;
-  else 
-    return GDK_NONE;
-}
-
index 6c8963a5b2fb38b400882f4d934c82eabcf83db9..c4b6d18890e0d08eed8bb0f760253a20634c6dcb 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <X11/Xlib.h>
-#include <X11/Xos.h>
-
-#include "gdkx.h"
 #include "gdkdrawable.h"
 #include "gdkprivate.h"
 #include "gdkwindow.h"
 
 /* Manipulation of drawables
  */
+GdkDrawable *
+gdk_drawable_alloc (void)
+{
+  GdkDrawablePrivate *private = g_new (GdkDrawablePrivate, 1);
+  GdkDrawable *drawable = (GdkDrawable*) private;
+  
+  drawable->user_data = NULL;
+
+  private->ref_count = 1;
+  private->destroyed = FALSE;
+  private->klass = NULL;
+  private->klass_data = NULL;
+  private->window_type = GDK_WINDOW_CHILD;
+
+  private->width = 1;
+  private->height = 1;
+
+  private->colormap = NULL;
+
+  return drawable;
+}
+
 void          
 gdk_drawable_set_data (GdkDrawable   *drawable,
                       const gchar   *key,
@@ -75,68 +93,6 @@ gdk_drawable_get_size (GdkDrawable *drawable,
     *height = drawable_private->height;
 }
 
-void
-gdk_drawable_set_colormap (GdkDrawable *drawable,
-                          GdkColormap *colormap)
-{
-  GdkDrawablePrivate *drawable_private;
-  GdkColormapPrivate *colormap_private;
-  
-  g_return_if_fail (drawable != NULL);
-  g_return_if_fail (colormap != NULL);
-  
-  drawable_private = (GdkDrawablePrivate*) drawable;
-  colormap_private = (GdkColormapPrivate*) colormap;
-  
-  if (!GDK_DRAWABLE_DESTROYED (drawable))
-    {
-      if (GDK_IS_WINDOW (drawable))
-       {
-         g_return_if_fail (colormap_private->visual !=
-                           ((GdkColormapPrivate *)(drawable_private->colormap))->visual);
-
-         XSetWindowColormap (GDK_DRAWABLE_XDISPLAY (drawable),
-                             GDK_DRAWABLE_XID (drawable),
-                             colormap_private->xcolormap);
-       }
-
-      if (drawable_private->colormap)
-       gdk_colormap_unref (drawable_private->colormap);
-      drawable_private->colormap = colormap;
-      gdk_colormap_ref (drawable_private->colormap);
-
-      if (GDK_IS_WINDOW (drawable) &&
-         drawable_private->window_type != GDK_WINDOW_TOPLEVEL)
-       gdk_window_add_colormap_windows (drawable);
-    }
-}
-
-GdkColormap*
-gdk_drawable_get_colormap (GdkDrawable *drawable)
-{
-  GdkDrawablePrivate *drawable_private;
-  XWindowAttributes window_attributes;
-  
-  g_return_val_if_fail (drawable != NULL, NULL);
-  drawable_private = (GdkDrawablePrivate*) drawable;
-  
-  if (!GDK_DRAWABLE_DESTROYED (drawable))
-    {
-      if (drawable_private->colormap == NULL &&
-         GDK_IS_WINDOW (drawable))
-       {
-         XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (drawable),
-                               GDK_DRAWABLE_XID (drawable),
-                               &window_attributes);
-         drawable_private->colormap =  gdk_colormap_lookup (window_attributes.colormap);
-       }
-
-      return drawable_private->colormap;
-    }
-  
-  return NULL;
-}
-
 GdkVisual*
 gdk_drawable_get_visual (GdkDrawable *drawable)
 {
@@ -148,6 +104,33 @@ gdk_drawable_get_visual (GdkDrawable *drawable)
   return colormap ? gdk_colormap_get_visual (colormap) : NULL;
 }
 
+GdkDrawable*
+gdk_drawable_ref (GdkDrawable *drawable)
+{
+  GdkDrawablePrivate *private = (GdkDrawablePrivate *)drawable;
+  g_return_val_if_fail (drawable != NULL, NULL);
+  
+  private->ref_count += 1;
+  return drawable;
+}
+
+void
+gdk_drawable_unref (GdkDrawable *drawable)
+{
+  GdkDrawablePrivate *private = (GdkDrawablePrivate *)drawable;
+  
+  g_return_if_fail (drawable != NULL);
+  g_return_if_fail (private->ref_count > 0);
+  
+  private->ref_count -= 1;
+  if (private->ref_count == 0)
+    {
+      private->klass->destroy (drawable);
+      g_dataset_destroy (drawable);
+      g_free (drawable);
+    }
+}
+
 /* Drawing
  */
 void
@@ -157,6 +140,7 @@ gdk_draw_point (GdkDrawable *drawable,
                 gint         y)
 {
   GdkGCPrivate *gc_private;
+  GdkPoint point;
 
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (gc != NULL);
@@ -165,8 +149,10 @@ gdk_draw_point (GdkDrawable *drawable,
     return;
   gc_private = (GdkGCPrivate*) gc;
 
-  XDrawPoint (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-              gc_private->xgc, x, y);
+  point.x = x;
+  point.y = y;
+  
+  ((GdkDrawablePrivate *)drawable)->klass->draw_points (drawable, gc, &point, 1);
 }
 
 void
@@ -178,6 +164,7 @@ gdk_draw_line (GdkDrawable *drawable,
               gint         y2)
 {
   GdkGCPrivate *gc_private;
+  GdkSegment segment;
 
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (gc != NULL);
@@ -186,8 +173,11 @@ gdk_draw_line (GdkDrawable *drawable,
     return;
   gc_private = (GdkGCPrivate*) gc;
 
-  XDrawLine (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-            gc_private->xgc, x1, y1, x2, y2);
+  segment.x1 = x1;
+  segment.y1 = y1;
+  segment.x2 = x2;
+  segment.y2 = y2;
+  ((GdkDrawablePrivate *)drawable)->klass->draw_segments (drawable, gc, &segment, 1);
 }
 
 void
@@ -200,7 +190,6 @@ gdk_draw_rectangle (GdkDrawable *drawable,
                    gint         height)
 {
   GdkDrawablePrivate *drawable_private;
-  GdkGCPrivate *gc_private;
 
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (gc != NULL);
@@ -208,19 +197,14 @@ gdk_draw_rectangle (GdkDrawable *drawable,
   drawable_private = (GdkDrawablePrivate*) drawable;
   if (GDK_DRAWABLE_DESTROYED (drawable))
     return;
-  gc_private = (GdkGCPrivate*) gc;
 
-  if (width == -1)
+  if (width < 0)
     width = drawable_private->width;
-  if (height == -1)
+  if (height < 0)
     height = drawable_private->height;
 
-  if (filled)
-    XFillRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                   gc_private->xgc, x, y, width, height);
-  else
-    XDrawRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                   gc_private->xgc, x, y, width, height);
+  ((GdkDrawablePrivate *)drawable)->klass->draw_rectangle (drawable, gc, filled, x, y,
+                                                          width, height);
 }
 
 void
@@ -245,17 +229,13 @@ gdk_draw_arc (GdkDrawable *drawable,
     return;
   gc_private = (GdkGCPrivate*) gc;
 
-  if (width == -1)
+  if (width < 0)
     width = drawable_private->width;
-  if (height == -1)
+  if (height < 0)
     height = drawable_private->height;
 
-  if (filled)
-    XFillArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-             gc_private->xgc, x, y, width, height, angle1, angle2);
-  else
-    XDrawArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-             gc_private->xgc, x, y, width, height, angle1, angle2);
+  ((GdkDrawablePrivate *)drawable)->klass->draw_arc (drawable, gc, filled,
+                                                    x, y, width, height, angle1, angle2);
 }
 
 void
@@ -265,44 +245,14 @@ gdk_draw_polygon (GdkDrawable *drawable,
                  GdkPoint    *points,
                  gint         npoints)
 {
-  GdkGCPrivate *gc_private;
-  GdkPoint *local_points = points;
-  gint local_npoints = npoints;
-  gint local_alloc = 0;
-
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (gc != NULL);
 
   if (GDK_DRAWABLE_DESTROYED (drawable))
     return;
-  gc_private = (GdkGCPrivate*) gc;
 
-  if (filled)
-    {
-      XFillPolygon (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                   gc_private->xgc, (XPoint*) points, npoints, Complex, CoordModeOrigin);
-    }
-  else
-    {
-      if ((points[0].x != points[npoints-1].x) ||
-        (points[0].y != points[npoints-1].y)) 
-        {
-          local_alloc = 1;
-          ++local_npoints;
-          local_points = (GdkPoint*) g_malloc (local_npoints * sizeof(GdkPoint));
-          memcpy (local_points, points, npoints * sizeof(GdkPoint));
-          local_points[npoints].x = points[0].x;
-          local_points[npoints].y = points[0].y;
-      }
-
-      XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                 gc_private->xgc,
-                 (XPoint*) local_points, local_npoints,
-                 CoordModeOrigin);
-  
-       if (local_alloc)
-       g_free (local_points);
-    }
+  ((GdkDrawablePrivate *)drawable)->klass->draw_polygon (drawable, gc, filled,
+                                                        points, npoints);
 }
 
 /* gdk_draw_string
@@ -319,43 +269,7 @@ gdk_draw_string (GdkDrawable *drawable,
                 gint         y,
                 const gchar *string)
 {
-  GdkFontPrivate *font_private;
-  GdkGCPrivate *gc_private;
-
-  g_return_if_fail (drawable != NULL);
-  g_return_if_fail (font != NULL);
-  g_return_if_fail (gc != NULL);
-  g_return_if_fail (string != NULL);
-
-  if (GDK_DRAWABLE_DESTROYED (drawable))
-    return;
-  gc_private = (GdkGCPrivate*) gc;
-  font_private = (GdkFontPrivate*) font;
-
-  if (font->type == GDK_FONT_FONT)
-    {
-      XFontStruct *xfont = (XFontStruct *) font_private->xfont;
-      XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid);
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                      gc_private->xgc, x, y, string, strlen (string));
-       }
-      else
-       {
-         XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                        gc_private->xgc, x, y, (XChar2b *) string,
-                        strlen (string) / 2);
-       }
-    }
-  else if (font->type == GDK_FONT_FONTSET)
-    {
-      XFontSet fontset = (XFontSet) font_private->xfont;
-      XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                    fontset, gc_private->xgc, x, y, string, strlen (string));
-    }
-  else
-    g_error("undefined font type\n");
+  gdk_draw_text (drawable, font, gc, x, y, string, _gdk_font_strlen (font, string));
 }
 
 /* gdk_draw_text
@@ -373,42 +287,12 @@ gdk_draw_text (GdkDrawable *drawable,
               const gchar *text,
               gint         text_length)
 {
-  GdkFontPrivate *font_private;
-  GdkGCPrivate *gc_private;
-
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (font != NULL);
   g_return_if_fail (gc != NULL);
   g_return_if_fail (text != NULL);
 
-  if (GDK_DRAWABLE_DESTROYED (drawable))
-    return;
-  gc_private = (GdkGCPrivate*) gc;
-  font_private = (GdkFontPrivate*) font;
-
-  if (font->type == GDK_FONT_FONT)
-    {
-      XFontStruct *xfont = (XFontStruct *) font_private->xfont;
-      XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid);
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                      gc_private->xgc, x, y, text, text_length);
-       }
-      else
-       {
-         XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                        gc_private->xgc, x, y, (XChar2b *) text, text_length / 2);
-       }
-    }
-  else if (font->type == GDK_FONT_FONTSET)
-    {
-      XFontSet fontset = (XFontSet) font_private->xfont;
-      XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                    fontset, gc_private->xgc, x, y, text, text_length);
-    }
-  else
-    g_error("undefined font type\n");
+  ((GdkDrawablePrivate *)drawable)->klass->draw_text (drawable, font, gc, x, y, text, text_length);
 }
 
 void
@@ -420,88 +304,40 @@ gdk_draw_text_wc (GdkDrawable      *drawable,
                  const GdkWChar *text,
                  gint            text_length)
 {
-  GdkFontPrivate *font_private;
-  GdkGCPrivate *gc_private;
-
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (font != NULL);
   g_return_if_fail (gc != NULL);
   g_return_if_fail (text != NULL);
 
-  if (GDK_DRAWABLE_DESTROYED (drawable))
-    return;
-  gc_private = (GdkGCPrivate*) gc;
-  font_private = (GdkFontPrivate*) font;
-
-  if (font->type == GDK_FONT_FONT)
-    {
-      XFontStruct *xfont = (XFontStruct *) font_private->xfont;
-      gchar *text_8bit;
-      gint i;
-      XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), gc_private->xgc, xfont->fid);
-      text_8bit = g_new (gchar, text_length);
-      for (i=0; i<text_length; i++) text_8bit[i] = text[i];
-      XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                   gc_private->xgc, x, y, text_8bit, text_length);
-      g_free (text_8bit);
-    }
-  else if (font->type == GDK_FONT_FONTSET)
-    {
-      if (sizeof(GdkWChar) == sizeof(wchar_t))
-       {
-         XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                        (XFontSet) font_private->xfont,
-                        gc_private->xgc, x, y, (wchar_t *)text, text_length);
-       }
-      else
-       {
-         wchar_t *text_wchar;
-         gint i;
-         text_wchar = g_new (wchar_t, text_length);
-         for (i=0; i<text_length; i++) text_wchar[i] = text[i];
-         XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
-                        (XFontSet) font_private->xfont,
-                        gc_private->xgc, x, y, text_wchar, text_length);
-         g_free (text_wchar);
-       }
-    }
-  else
-    g_error("undefined font type\n");
+  ((GdkDrawablePrivate *)drawable)->klass->draw_text_wc (drawable, font, gc, x, y, text, text_length);
 }
 
 void
-gdk_draw_pixmap (GdkDrawable *drawable,
-                GdkGC       *gc,
-                GdkPixmap   *src,
-                gint         xsrc,
-                gint         ysrc,
-                gint         xdest,
-                gint         ydest,
-                gint         width,
-                gint         height)
+gdk_draw_drawable (GdkDrawable *drawable,
+                  GdkGC       *gc,
+                  GdkDrawable *src,
+                  gint         xsrc,
+                  gint         ysrc,
+                  gint         xdest,
+                  gint         ydest,
+                  gint         width,
+                  gint         height)
 {
-  GdkGCPrivate *gc_private;
-
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (src != NULL);
   g_return_if_fail (gc != NULL);
 
   if (GDK_DRAWABLE_DESTROYED (drawable) || GDK_DRAWABLE_DESTROYED (src))
     return;
-  gc_private = (GdkGCPrivate*) gc;
 
   if (width == -1)
     width = ((GdkDrawablePrivate *)src)->width;
   if (height == -1)
     height = ((GdkDrawablePrivate *)src)->height;
 
-  XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable),
-            GDK_DRAWABLE_XID (src),
-            GDK_DRAWABLE_XID (drawable),
-            gc_private->xgc,
-            xsrc, ysrc,
-            width, height,
-            xdest, ydest);
+  ((GdkDrawablePrivate *)drawable)->klass->draw_drawable (drawable, gc, src,
+                                                         xsrc, ysrc, xdest, ydest,
+                                                         width, height);
 }
 
 void
@@ -523,15 +359,14 @@ gdk_draw_image (GdkDrawable *drawable,
 
   image_private = (GdkImagePrivate*) image;
 
-  g_return_if_fail (image_private->image_put != NULL);
-
   if (width == -1)
     width = image->width;
   if (height == -1)
     height = image->height;
 
-  (* image_private->image_put) (drawable, gc, image, xsrc, ysrc,
-                               xdest, ydest, width, height);
+
+  image_private->klass->image_put (image, drawable, gc, xsrc, ysrc,
+                                  xdest, ydest, width, height);
 }
 
 void
@@ -540,22 +375,18 @@ gdk_draw_points (GdkDrawable *drawable,
                 GdkPoint    *points,
                 gint         npoints)
 {
-  GdkGCPrivate *gc_private;
-
   g_return_if_fail (drawable != NULL);
   g_return_if_fail ((points != NULL) && (npoints > 0));
   g_return_if_fail (gc != NULL);
+  g_return_if_fail (npoints >= 0);
+
+  if (npoints == 0)
+    return;
 
   if (GDK_DRAWABLE_DESTROYED (drawable))
     return;
-  gc_private = (GdkGCPrivate*) gc;
 
-  XDrawPoints (GDK_DRAWABLE_XDISPLAY (drawable),
-              GDK_DRAWABLE_XID (drawable),
-              gc_private->xgc,
-              (XPoint *) points,
-              npoints,
-              CoordModeOrigin);
+  ((GdkDrawablePrivate *)drawable)->klass->draw_points (drawable, gc, points, npoints);
 }
 
 void
@@ -564,49 +395,37 @@ gdk_draw_segments (GdkDrawable *drawable,
                   GdkSegment  *segs,
                   gint         nsegs)
 {
-  GdkGCPrivate *gc_private;
-
-  if (nsegs <= 0)
-    return;
-
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (segs != NULL);
   g_return_if_fail (gc != NULL);
+  g_return_if_fail (nsegs >= 0);
+
+  if (nsegs == 0)
+    return;
 
   if (GDK_DRAWABLE_DESTROYED (drawable))
     return;
-  gc_private = (GdkGCPrivate*) gc;
 
-  XDrawSegments (GDK_DRAWABLE_XDISPLAY (drawable),
-                GDK_DRAWABLE_XID (drawable),
-                gc_private->xgc,
-                (XSegment *) segs,
-                nsegs);
+  ((GdkDrawablePrivate *)drawable)->klass->draw_segments (drawable, gc, segs, nsegs);
 }
 
 void
 gdk_draw_lines (GdkDrawable *drawable,
-              GdkGC       *gc,
-              GdkPoint    *points,
-              gint         npoints)
+               GdkGC       *gc,
+               GdkPoint    *points,
+               gint         npoints)
 {
-  GdkGCPrivate *gc_private;
-
-  if (npoints <= 0)
-    return;
 
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (points != NULL);
   g_return_if_fail (gc != NULL);
+  g_return_if_fail (npoints >= 0);
+
+  if (npoints == 0)
+    return;
 
   if (GDK_DRAWABLE_DESTROYED (drawable))
     return;
-  gc_private = (GdkGCPrivate*) gc;
 
-  XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable),
-             GDK_DRAWABLE_XID (drawable),
-             gc_private->xgc,
-             (XPoint *) points,
-             npoints,
-             CoordModeOrigin);
+  ((GdkDrawablePrivate *)drawable)->klass->draw_points (drawable, gc, points, npoints);
 }
index b3286c4823ba098985bf6a4eeb54418885637523..80d797ef537c68cc9018f425ce85eccafc5977b2 100644 (file)
@@ -2,11 +2,14 @@
 #define __GDK_DRAWABLE_H__
 
 #include <gdk/gdktypes.h>
+#include <gdk/gdkgc.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
+typedef struct _GdkDrawableClass GdkDrawableClass;
+
 /* Types of windows.
  *   Root: There is only 1 root window and it is initialized
  *        at startup. Creating a window of type GDK_WINDOW_ROOT
@@ -42,9 +45,75 @@ struct _GdkDrawable
 {
   gpointer user_data;
 };
+struct _GdkDrawableClass 
+{
+  void  (*destroy)       (GdkDrawable    *drawable);
+  GdkGC *(*create_gc)    (GdkDrawable    *drawable,
+                         GdkGCValues    *values,
+                         GdkGCValuesMask mask);
+  void (*draw_rectangle) (GdkDrawable  *drawable,
+                         GdkGC        *gc,
+                         gint          filled,
+                         gint          x,
+                         gint          y,
+                         gint          width,
+                         gint          height);
+  void (*draw_arc)       (GdkDrawable  *drawable,
+                         GdkGC        *gc,
+                         gint          filled,
+                         gint          x,
+                         gint          y,
+                         gint          width,
+                         gint          height,
+                         gint          angle1,
+                         gint          angle2);
+  void (*draw_polygon)   (GdkDrawable  *drawable,
+                         GdkGC        *gc,
+                         gint          filled,
+                         GdkPoint     *points,
+                         gint          npoints);
+  void (*draw_text)      (GdkDrawable  *drawable,
+                         GdkFont      *font,
+                         GdkGC        *gc,
+                         gint          x,
+                         gint          y,
+                         const gchar  *text,
+                         gint          text_length);
+  void (*draw_text_wc)   (GdkDrawable   *drawable,
+                         GdkFont        *font,
+                         GdkGC          *gc,
+                         gint            x,
+                         gint            y,
+                         const GdkWChar *text,
+                         gint            text_length);
+  void (*draw_drawable)  (GdkDrawable  *drawable,
+                         GdkGC        *gc,
+                         GdkDrawable  *src,
+                         gint          xsrc,
+                         gint          ysrc,
+                         gint          xdest,
+                         gint          ydest,
+                         gint          width,
+                         gint          height);
+  void (*draw_points)   (GdkDrawable  *drawable,
+                         GdkGC        *gc,
+                         GdkPoint     *points,
+                         gint          npoints);
+  void (*draw_segments)         (GdkDrawable  *drawable,
+                         GdkGC        *gc,
+                         GdkSegment   *segs,
+                         gint          nsegs);
+  void (*draw_lines)     (GdkDrawable  *drawable,
+                         GdkGC        *gc,
+                         GdkPoint     *points,
+                         gint          npoints);
+};
 
 /* Manipulation of drawables
  */
+GdkDrawable *   gdk_drawable_alloc        (void);
+
 GdkDrawableType gdk_drawable_get_type     (GdkDrawable   *window);
 
 void            gdk_drawable_set_data     (GdkDrawable    *drawable,
@@ -61,6 +130,8 @@ void         gdk_drawable_set_colormap (GdkDrawable    *drawable,
                                           GdkColormap    *colormap);
 GdkColormap*    gdk_drawable_get_colormap (GdkDrawable   *drawable);
 GdkVisual*      gdk_drawable_get_visual   (GdkDrawable   *drawable);
+GdkDrawable*    gdk_drawable_ref          (GdkDrawable    *drawable);
+void            gdk_drawable_unref        (GdkDrawable    *drawable);
 
 /* Drawing
  */
@@ -115,16 +186,7 @@ void gdk_draw_text_wc       (GdkDrawable    *drawable,
                          gint            y,
                          const GdkWChar *text,
                          gint            text_length);
-void gdk_draw_pixmap    (GdkDrawable  *drawable,
-                         GdkGC        *gc,
-                         GdkDrawable  *src,
-                         gint          xsrc,
-                         gint          ysrc,
-                         gint          xdest,
-                         gint          ydest,
-                         gint          width,
-                         gint          height);
-void gdk_draw_bitmap    (GdkDrawable  *drawable,
+void gdk_draw_drawable  (GdkDrawable  *drawable,
                          GdkGC        *gc,
                          GdkDrawable  *src,
                          gint          xsrc,
index 1738a0dbbeb29f209dc9543372a13d6737e64ff7..d38c6c751b407845a4b33d58b8da73e56b73067d 100644 (file)
 
 #include "gdk.h"
 #include "gdkprivate.h"
-#include "gdkx.h"
-
-#include "gdkkeysyms.h"
-
-#if HAVE_CONFIG_H
-#  include <config.h>
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#endif
-
-#include "gdkinputprivate.h"
 
 typedef struct _GdkIOClosure GdkIOClosure;
 typedef struct _GdkEventPrivate GdkEventPrivate;
@@ -73,34 +61,6 @@ struct _GdkEventPrivate
  * Private function declarations
  */
 
-static GdkEvent *gdk_event_new         (void);
-static gint     gdk_event_apply_filters (XEvent   *xevent,
-                                         GdkEvent *event,
-                                         GList    *filters);
-static gint     gdk_event_translate     (GdkEvent *event, 
-                                         XEvent   *xevent);
-#if 0
-static Bool     gdk_event_get_type     (Display   *display, 
-                                        XEvent    *xevent, 
-                                        XPointer   arg);
-#endif
-static void      gdk_events_queue       (void);
-static GdkEvent* gdk_event_unqueue      (void);
-
-static gboolean  gdk_event_prepare      (gpointer   source_data, 
-                                        GTimeVal  *current_time,
-                                        gint      *timeout,
-                                        gpointer   user_data);
-static gboolean  gdk_event_check        (gpointer   source_data,
-                                        GTimeVal  *current_time,
-                                        gpointer   user_data);
-static gboolean  gdk_event_dispatch     (gpointer   source_data,
-                                        GTimeVal  *current_time,
-                                        gpointer   user_data);
-
-static void     gdk_synthesize_click   (GdkEvent  *event, 
-                                        gint       nclicks);
-
 GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
                                         GdkEvent  *event,
                                         gpointer   data);
@@ -108,40 +68,19 @@ GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
 /* Private variable declarations
  */
 
-static int connection_number = 0;          /* The file descriptor number of our
-                                            *  connection to the X server. This
-                                            *  is used so that we may determine
-                                            *  when events are pending by using
-                                            *  the "select" system call.
+static guint32 button_click_time[2] = { 0, 0}; /* The last 2 button click times. Used
+                                               * to determine if the latest button click
+                                               * is part of a double or triple click.
+                                               */
+static GdkWindow *button_window[2] = { NULL, NULL}; /* The last 2 windows to receive button presses.
+                                                    *  Also used to determine if the latest button
+                                                    *  click is part of a double or triple click.
                                             */
-static guint32 button_click_time[2];       /* The last 2 button click times. Used
-                                            *  to determine if the latest button click
-                                            *  is part of a double or triple click.
+static guint button_number[2] = { -1, -1 }; /* The last 2 buttons to be pressed.
                                             */
-static GdkWindow *button_window[2];        /* The last 2 windows to receive button presses.
-                                            *  Also used to determine if the latest button
-                                            *  click is part of a double or triple click.
-                                            */
-static guint button_number[2];             /* The last 2 buttons to be pressed.
-                                            */
-static GdkEventFunc   event_func = NULL;    /* Callback for events */
-static gpointer       event_data = NULL;
-static GDestroyNotify event_notify = NULL;
-
-static GList *client_filters;              /* Filters for client messages */
-
-/* FIFO's for event queue, and for events put back using
- * gdk_event_put().
- */
-static GList *queued_events = NULL;
-static GList *queued_tail = NULL;
-
-static GSourceFuncs event_funcs = {
-  gdk_event_prepare,
-  gdk_event_check,
-  gdk_event_dispatch,
-  (GDestroyNotify)g_free
-};
+GdkEventFunc   gdk_event_func = NULL;    /* Callback for events */
+gpointer       gdk_event_data = NULL;
+GDestroyNotify gdk_event_notify = NULL;
 
 GPollFD event_poll_fd;
 
@@ -159,10 +98,10 @@ GPollFD event_poll_fd;
  *     Pointer to the list node for that event, or NULL
  *************************************************************/
 
-static GList*
+GList*
 gdk_event_queue_find_first (void)
 {
-  GList *tmp_list = queued_events;
+  GList *tmp_list = gdk_queued_events;
 
   while (tmp_list)
     {
@@ -184,18 +123,18 @@ gdk_event_queue_find_first (void)
  *   results:
  *************************************************************/
 
-static void
+void
 gdk_event_queue_remove_link (GList *node)
 {
   if (node->prev)
     node->prev->next = node->next;
   else
-    queued_events = node->next;
+    gdk_queued_events = node->next;
   
   if (node->next)
     node->next->prev = node->prev;
   else
-    queued_tail = node->prev;
+    gdk_queued_tail = node->prev;
   
 }
 
@@ -207,322 +146,15 @@ gdk_event_queue_remove_link (GList *node)
  *   results:
  *************************************************************/
 
-static void
+void
 gdk_event_queue_append (GdkEvent *event)
 {
-  queued_tail = g_list_append (queued_tail, event);
+  gdk_queued_tail = g_list_append (gdk_queued_tail, event);
   
-  if (!queued_events)
-    queued_events = queued_tail;
+  if (!gdk_queued_events)
+    gdk_queued_events = gdk_queued_tail;
   else
-    queued_tail = queued_tail->next;
-}
-
-void 
-gdk_events_init (void)
-{
-  connection_number = ConnectionNumber (gdk_display);
-  GDK_NOTE (MISC,
-           g_message ("connection number: %d", connection_number));
-
-  g_source_add (GDK_PRIORITY_EVENTS, TRUE, &event_funcs, NULL, NULL, NULL);
-
-  event_poll_fd.fd = connection_number;
-  event_poll_fd.events = G_IO_IN;
-  
-  g_main_add_poll (&event_poll_fd, GDK_PRIORITY_EVENTS);
-
-  button_click_time[0] = 0;
-  button_click_time[1] = 0;
-  button_window[0] = NULL;
-  button_window[1] = NULL;
-  button_number[0] = -1;
-  button_number[1] = -1;
-
-  gdk_add_client_message_filter (gdk_wm_protocols, 
-                                gdk_wm_protocols_filter, NULL);
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_events_pending
- *
- *   Returns if events are pending on the queue.
- *
- * Arguments:
- *
- * Results:
- *   Returns TRUE if events are pending
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-gboolean
-gdk_events_pending (void)
-{
-  return (gdk_event_queue_find_first() || XPending (gdk_display));
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_event_get_graphics_expose
- *
- *   Waits for a GraphicsExpose or NoExpose event
- *
- * Arguments:
- *
- * Results: 
- *   For GraphicsExpose events, returns a pointer to the event
- *   converted into a GdkEvent Otherwise, returns NULL.
- *
- * Side effects:
- *
- *-------------------------------------------------------------- */
-
-static Bool
-graphics_expose_predicate (Display  *display,
-                          XEvent   *xevent,
-                          XPointer  arg)
-{
-  if (xevent->xany.window == GDK_DRAWABLE_XID (arg) &&
-      (xevent->xany.type == GraphicsExpose ||
-       xevent->xany.type == NoExpose))
-    return True;
-  else
-    return False;
-}
-
-GdkEvent*
-gdk_event_get_graphics_expose (GdkWindow *window)
-{
-  XEvent xevent;
-  GdkEvent *event;
-  
-  g_return_val_if_fail (window != NULL, NULL);
-  
-  XIfEvent (gdk_display, &xevent, graphics_expose_predicate, (XPointer) window);
-  
-  if (xevent.xany.type == GraphicsExpose)
-    {
-      event = gdk_event_new ();
-      
-      if (gdk_event_translate (event, &xevent))
-       return event;
-      else
-       gdk_event_free (event);
-    }
-  
-  return NULL; 
-}
-
-/************************
- * Exposure compression *
- ************************/
-
-/*
- * The following implements simple exposure compression. It is
- * modelled after the way Xt does exposure compression - in
- * particular compress_expose = XtExposeCompressMultiple.
- * It compress consecutive sequences of exposure events,
- * but not sequences that cross other events. (This is because
- * if it crosses a ConfigureNotify, we could screw up and
- * mistakenly compress the exposures generated for the new
- * size - could we just check for ConfigureNotify?)
- *
- * Xt compresses to a region / bounding rectangle, we compress
- * to two rectangles, and try find the two rectangles of minimal
- * area for this - this is supposed to handle the typical
- * L-shaped regions generated by OpaqueMove.
- */
-
-/* Given three rectangles, find the two rectangles that cover
- * them with the smallest area.
- */
-static void
-gdk_add_rect_to_rects (GdkRectangle *rect1,
-                      GdkRectangle *rect2, 
-                      GdkRectangle *new_rect)
-{
-  GdkRectangle t1, t2, t3;
-  gint size1, size2, size3;
-
-  gdk_rectangle_union (rect1, rect2, &t1);
-  gdk_rectangle_union (rect1, new_rect, &t2);
-  gdk_rectangle_union (rect2, new_rect, &t3);
-
-  size1 = t1.width * t1.height + new_rect->width * new_rect->height;
-  size2 = t2.width * t2.height + rect2->width * rect2->height;
-  size3 = t1.width * t1.height + rect1->width * rect1->height;
-
-  if (size1 < size2)
-    {
-      if (size1 < size3)
-       {
-         *rect1 = t1;
-         *rect2 = *new_rect;
-       }
-      else
-       *rect2 = t3;
-    }
-  else
-    {
-      if (size2 < size3)
-       *rect1 = t2;
-      else
-       *rect2 = t3;
-    }
-}
-
-typedef struct _GdkExposeInfo GdkExposeInfo;
-
-struct _GdkExposeInfo
-{
-  Window window;
-  gboolean seen_nonmatching;
-};
-
-static Bool
-expose_predicate (Display *display,
-                 XEvent  *xevent,
-                 XPointer arg)
-{
-  GdkExposeInfo *info = (GdkExposeInfo*) arg;
-
-  /* Compressing across GravityNotify events is safe, because
-   * we completely ignore them, so they can't change what
-   * we are going to draw. Compressing across GravityNotify
-   * events is necessay because during window-unshading animation
-   * we'll get a whole bunch of them interspersed with
-   * expose events.
-   */
-  if (xevent->xany.type != Expose && 
-      xevent->xany.type != GravityNotify)
-    {
-      info->seen_nonmatching = TRUE;
-    }
-
-  if (info->seen_nonmatching ||
-      xevent->xany.type != Expose ||
-      xevent->xany.window != info->window)
-    return FALSE;
-  else
-    return TRUE;
-}
-
-void
-gdk_compress_exposures (XEvent    *xevent,
-                       GdkWindow *window)
-{
-  gint nrects = 1;
-  gint count = 0;
-  GdkRectangle rect1;
-  GdkRectangle rect2;
-  GdkRectangle tmp_rect;
-  XEvent tmp_event;
-  GdkFilterReturn result;
-  GdkExposeInfo info;
-  GdkEvent event;
-
-  info.window = xevent->xany.window;
-  info.seen_nonmatching = FALSE;
-  
-  rect1.x = xevent->xexpose.x;
-  rect1.y = xevent->xexpose.y;
-  rect1.width = xevent->xexpose.width;
-  rect1.height = xevent->xexpose.height;
-
-  event.any.type = GDK_EXPOSE;
-  event.any.window = None;
-  event.any.send_event = FALSE;
-  
-  while (1)
-    {
-      if (count == 0)
-       {
-         if (!XCheckIfEvent (gdk_display, 
-                             &tmp_event, 
-                             expose_predicate, 
-                             (XPointer)&info))
-           break;
-       }
-      else
-       XIfEvent (gdk_display, 
-                 &tmp_event, 
-                 expose_predicate, 
-                 (XPointer)&info);
-
-      event.any.window = window;
-      
-      /* We apply filters here, and if it was filtered, completely
-       * ignore the return
-       */
-      result = gdk_event_apply_filters (xevent, &event,
-                                       window ? 
-                                         ((GdkWindowPrivate *)window)->filters
-                                         : gdk_default_filters);
-      
-      if (result != GDK_FILTER_CONTINUE)
-       {
-         if (result == GDK_FILTER_TRANSLATE)
-           gdk_event_put (&event);
-         continue;
-       }
-
-      if (nrects == 1)
-       {
-         rect2.x = tmp_event.xexpose.x;
-         rect2.y = tmp_event.xexpose.y;
-         rect2.width = tmp_event.xexpose.width;
-         rect2.height = tmp_event.xexpose.height;
-
-         nrects++;
-       }
-      else
-       {
-         tmp_rect.x = tmp_event.xexpose.x;
-         tmp_rect.y = tmp_event.xexpose.y;
-         tmp_rect.width = tmp_event.xexpose.width;
-         tmp_rect.height = tmp_event.xexpose.height;
-
-         gdk_add_rect_to_rects (&rect1, &rect2, &tmp_rect);
-       }
-
-      count = tmp_event.xexpose.count;
-    }
-
-  if (nrects == 2)
-    {
-      gdk_rectangle_union (&rect1, &rect2, &tmp_rect);
-
-      if ((tmp_rect.width * tmp_rect.height) <
-         2 * (rect1.height * rect1.width +
-              rect2.height * rect2.width))
-       {
-         rect1 = tmp_rect;
-         nrects = 1;
-       }
-    }
-
-  if (nrects == 2)
-    {
-      event.expose.type = GDK_EXPOSE;
-      event.expose.window = window;
-      event.expose.area.x = rect2.x;
-      event.expose.area.y = rect2.y;
-      event.expose.area.width = rect2.width;
-      event.expose.area.height = rect2.height;
-      event.expose.count = 0;
-
-      gdk_event_put (&event);
-    }
-
-  xevent->xexpose.count = nrects - 1;
-  xevent->xexpose.x = rect1.x;
-  xevent->xexpose.y = rect1.y;
-  xevent->xexpose.width = rect1.width;
-  xevent->xexpose.height = rect1.height;
+    gdk_queued_tail = gdk_queued_tail->next;
 }
 
 /*************************************************************
@@ -541,12 +173,12 @@ gdk_event_handler_set (GdkEventFunc   func,
                       gpointer       data,
                       GDestroyNotify notify)
 {
-  if (event_notify)
-    (*event_notify) (event_data);
+  if (gdk_event_notify)
+    (*gdk_event_notify) (gdk_event_data);
 
-  event_func = func;
-  event_data = data;
-  event_notify = notify;
+  gdk_event_func = func;
+  gdk_event_data = data;
+  gdk_event_notify = notify;
 }
 
 /*
@@ -639,7 +271,7 @@ gdk_event_put (GdkEvent *event)
 
 static GMemChunk *event_chunk = NULL;
 
-static GdkEvent*
+GdkEvent*
 gdk_event_new (void)
 {
   GdkEventPrivate *new_event;
@@ -929,1142 +561,7 @@ gdk_input_remove (gint tag)
   g_source_remove (tag);
 }
 
-static gint
-gdk_event_apply_filters (XEvent *xevent,
-                        GdkEvent *event,
-                        GList *filters)
-{
-  GList *tmp_list;
-  GdkFilterReturn result;
-  
-  tmp_list = filters;
-  
-  while (tmp_list)
-    {
-      GdkEventFilter *filter = (GdkEventFilter*) tmp_list->data;
-      
-      tmp_list = tmp_list->next;
-      result = filter->function (xevent, event, filter->data);
-      if (result !=  GDK_FILTER_CONTINUE)
-       return result;
-    }
-  
-  return GDK_FILTER_CONTINUE;
-}
-
-void 
-gdk_add_client_message_filter (GdkAtom       message_type,
-                              GdkFilterFunc func,
-                              gpointer      data)
-{
-  GdkClientFilter *filter = g_new (GdkClientFilter, 1);
-
-  filter->type = message_type;
-  filter->function = func;
-  filter->data = data;
-  
-  client_filters = g_list_prepend (client_filters, filter);
-}
-
-static gint
-gdk_event_translate (GdkEvent *event,
-                    XEvent   *xevent)
-{
-  
-  GdkWindow *window;
-  GdkWindowPrivate *window_private;
-  static XComposeStatus compose;
-  KeySym keysym;
-  int charcount;
-#ifdef USE_XIM
-  static gchar* buf = NULL;
-  static gint buf_len= 0;
-#else
-  char buf[16];
-#endif
-  gint return_val;
-  
-  return_val = FALSE;
-  
-  /* Find the GdkWindow that this event occurred in.
-   * 
-   * We handle events with window=None
-   *  specially - they are generated by XFree86's XInput under
-   *  some circumstances.
-   */
-  
-  if ((xevent->xany.window == None) &&
-      gdk_input_vtable.window_none_event)
-    {
-      return_val = gdk_input_vtable.window_none_event (event,xevent);
-      
-      if (return_val >= 0)     /* was handled */
-       return return_val;
-      else
-       return_val = FALSE;
-    }
-  
-  window = gdk_window_lookup (xevent->xany.window);
-  /* FIXME: window might be a GdkPixmap!!! */
-  
-  window_private = (GdkWindowPrivate *) window;
-  
-  if (window != NULL)
-    gdk_window_ref (window);
-  
-  event->any.window = window;
-  event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
-  
-  if (window_private && GDK_DRAWABLE_DESTROYED (window))
-    {
-      if (xevent->type != DestroyNotify)
-       return FALSE;
-    }
-  else
-    {
-      /* Check for filters for this window
-       */
-      GdkFilterReturn result;
-      result = gdk_event_apply_filters (xevent, event,
-                                       window_private
-                                       ?window_private->filters
-                                       :gdk_default_filters);
-      
-      if (result != GDK_FILTER_CONTINUE)
-       {
-         return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
-       }
-    }
-
-#ifdef USE_XIM
-  if (window == NULL && gdk_xim_window && xevent->type == KeyPress &&
-      !GDK_DRAWABLE_DESTROYED (gdk_xim_window))
-    {
-      /*
-       * If user presses a key in Preedit or Status window, keypress event
-       * is sometimes sent to these windows. These windows are not managed
-       * by GDK, so we redirect KeyPress event to xim_window.
-       *
-       * If someone want to use the window whitch is not managed by GDK
-       * and want to get KeyPress event, he/she must register the filter
-       * function to gdk_default_filters to intercept the event.
-       */
-
-      GdkFilterReturn result;
-
-      window = gdk_xim_window;
-      window_private = (GdkWindowPrivate *) window;
-      gdk_window_ref (window);
-      event->any.window = window;
-
-      GDK_NOTE (XIM,
-       g_message ("KeyPress event is redirected to xim_window: %#lx",
-                  xevent->xany.window));
-
-      result = gdk_event_apply_filters (xevent, event,
-                                       window_private->filters);
-      if (result != GDK_FILTER_CONTINUE)
-       return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
-    }
-#endif
-
-  /* We do a "manual" conversion of the XEvent to a
-   *  GdkEvent. The structures are mostly the same so
-   *  the conversion is fairly straightforward. We also
-   *  optionally print debugging info regarding events
-   *  received.
-   */
-
-  return_val = TRUE;
-
-  switch (xevent->type)
-    {
-    case KeyPress:
-      /* Lookup the string corresponding to the given keysym.
-       */
-      
-#ifdef USE_XIM
-      if (buf_len == 0) 
-       {
-         buf_len = 128;
-         buf = g_new (gchar, buf_len);
-       }
-      keysym = GDK_VoidSymbol;
-      
-      if (gdk_xim_ic && gdk_xim_ic->xic)
-       {
-         Status status;
-         
-         /* Clear keyval. Depending on status, may not be set */
-         charcount = XmbLookupString(gdk_xim_ic->xic,
-                                     &xevent->xkey, buf, buf_len-1,
-                                     &keysym, &status);
-         if (status == XBufferOverflow)
-           {                     /* retry */
-             /* alloc adequate size of buffer */
-             GDK_NOTE (XIM,
-                       g_message("XIM: overflow (required %i)", charcount));
-             
-             while (buf_len <= charcount)
-               buf_len *= 2;
-             buf = (gchar *) g_realloc (buf, buf_len);
-             
-             charcount = XmbLookupString (gdk_xim_ic->xic,
-                                          &xevent->xkey, buf, buf_len-1,
-                                          &keysym, &status);
-           }
-         if (status == XLookupNone)
-           {
-             return_val = FALSE;
-             break;
-           }
-       }
-      else
-       charcount = XLookupString (&xevent->xkey, buf, buf_len,
-                                  &keysym, &compose);
-#else
-      charcount = XLookupString (&xevent->xkey, buf, 16,
-                                &keysym, &compose);
-#endif
-      event->key.keyval = keysym;
-      
-      if (charcount > 0 && buf[charcount-1] == '\0')
-       charcount --;
-      else
-       buf[charcount] = '\0';
-      
-      /* Print debugging info. */
-      
-#ifdef G_ENABLE_DEBUG
-      if (gdk_debug_flags & GDK_DEBUG_EVENTS)
-       {
-         g_message ("key press:\twindow: %ld  key: %12s  %d",
-                    xevent->xkey.window,
-                    event->key.keyval ? XKeysymToString (event->key.keyval) : "(none)",
-                    event->key.keyval);
-         if (charcount > 0)
-           g_message ("\t\tlength: %4d string: \"%s\"",
-                      charcount, buf);
-       }
-#endif /* G_ENABLE_DEBUG */
-      
-      event->key.type = GDK_KEY_PRESS;
-      event->key.window = window;
-      event->key.time = xevent->xkey.time;
-      event->key.state = (GdkModifierType) xevent->xkey.state;
-      event->key.string = g_strdup (buf);
-      event->key.length = charcount;
-      
-      break;
-      
-    case KeyRelease:
-      /* Lookup the string corresponding to the given keysym.
-       */
-#ifdef USE_XIM
-      if (buf_len == 0) 
-       {
-         buf_len = 128;
-         buf = g_new (gchar, buf_len);
-       }
-#endif
-      keysym = GDK_VoidSymbol;
-      charcount = XLookupString (&xevent->xkey, buf, 16,
-                                &keysym, &compose);
-      event->key.keyval = keysym;      
-      
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS, 
-               g_message ("key release:\t\twindow: %ld  key: %12s  %d",
-                          xevent->xkey.window,
-                          XKeysymToString (event->key.keyval),
-                          event->key.keyval));
-      
-      event->key.type = GDK_KEY_RELEASE;
-      event->key.window = window;
-      event->key.time = xevent->xkey.time;
-      event->key.state = (GdkModifierType) xevent->xkey.state;
-      event->key.length = 0;
-      event->key.string = NULL;
-      
-      break;
-      
-    case ButtonPress:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS, 
-               g_message ("button press:\t\twindow: %ld  x,y: %d %d  button: %d",
-                          xevent->xbutton.window,
-                          xevent->xbutton.x, xevent->xbutton.y,
-                          xevent->xbutton.button));
-      
-      if (window_private &&
-         (window_private->extension_events != 0) &&
-         gdk_input_ignore_core)
-       {
-         return_val = FALSE;
-         break;
-       }
-      
-      event->button.type = GDK_BUTTON_PRESS;
-      event->button.window = window;
-      event->button.time = xevent->xbutton.time;
-      event->button.x = xevent->xbutton.x;
-      event->button.y = xevent->xbutton.y;
-      event->button.x_root = (gfloat)xevent->xbutton.x_root;
-      event->button.y_root = (gfloat)xevent->xbutton.y_root;
-      event->button.pressure = 0.5;
-      event->button.xtilt = 0;
-      event->button.ytilt = 0;
-      event->button.state = (GdkModifierType) xevent->xbutton.state;
-      event->button.button = xevent->xbutton.button;
-      event->button.source = GDK_SOURCE_MOUSE;
-      event->button.deviceid = GDK_CORE_POINTER;
-      
-      if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
-         (event->button.window == button_window[1]) &&
-         (event->button.button == button_number[1]))
-       {
-         gdk_synthesize_click (event, 3);
-         
-         button_click_time[1] = 0;
-         button_click_time[0] = 0;
-         button_window[1] = NULL;
-         button_window[0] = 0;
-         button_number[1] = -1;
-         button_number[0] = -1;
-       }
-      else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
-              (event->button.window == button_window[0]) &&
-              (event->button.button == button_number[0]))
-       {
-         gdk_synthesize_click (event, 2);
-         
-         button_click_time[1] = button_click_time[0];
-         button_click_time[0] = event->button.time;
-         button_window[1] = button_window[0];
-         button_window[0] = event->button.window;
-         button_number[1] = button_number[0];
-         button_number[0] = event->button.button;
-       }
-      else
-       {
-         button_click_time[1] = 0;
-         button_click_time[0] = event->button.time;
-         button_window[1] = NULL;
-         button_window[0] = event->button.window;
-         button_number[1] = -1;
-         button_number[0] = event->button.button;
-       }
-
-      break;
-      
-    case ButtonRelease:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS, 
-               g_message ("button release:\twindow: %ld  x,y: %d %d  button: %d",
-                          xevent->xbutton.window,
-                          xevent->xbutton.x, xevent->xbutton.y,
-                          xevent->xbutton.button));
-      
-      if (window_private &&
-         (window_private->extension_events != 0) &&
-         gdk_input_ignore_core)
-       {
-         return_val = FALSE;
-         break;
-       }
-      
-      event->button.type = GDK_BUTTON_RELEASE;
-      event->button.window = window;
-      event->button.time = xevent->xbutton.time;
-      event->button.x = xevent->xbutton.x;
-      event->button.y = xevent->xbutton.y;
-      event->button.x_root = (gfloat)xevent->xbutton.x_root;
-      event->button.y_root = (gfloat)xevent->xbutton.y_root;
-      event->button.pressure = 0.5;
-      event->button.xtilt = 0;
-      event->button.ytilt = 0;
-      event->button.state = (GdkModifierType) xevent->xbutton.state;
-      event->button.button = xevent->xbutton.button;
-      event->button.source = GDK_SOURCE_MOUSE;
-      event->button.deviceid = GDK_CORE_POINTER;
-      
-      break;
-      
-    case MotionNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("motion notify:\t\twindow: %ld  x,y: %d %d  hint: %s", 
-                          xevent->xmotion.window,
-                          xevent->xmotion.x, xevent->xmotion.y,
-                          (xevent->xmotion.is_hint) ? "true" : "false"));
-      
-      if (window_private &&
-         (window_private->extension_events != 0) &&
-         gdk_input_ignore_core)
-       {
-         return_val = FALSE;
-         break;
-       }
-      
-      event->motion.type = GDK_MOTION_NOTIFY;
-      event->motion.window = window;
-      event->motion.time = xevent->xmotion.time;
-      event->motion.x = xevent->xmotion.x;
-      event->motion.y = xevent->xmotion.y;
-      event->motion.x_root = (gfloat)xevent->xmotion.x_root;
-      event->motion.y_root = (gfloat)xevent->xmotion.y_root;
-      event->motion.pressure = 0.5;
-      event->motion.xtilt = 0;
-      event->motion.ytilt = 0;
-      event->motion.state = (GdkModifierType) xevent->xmotion.state;
-      event->motion.is_hint = xevent->xmotion.is_hint;
-      event->motion.source = GDK_SOURCE_MOUSE;
-      event->motion.deviceid = GDK_CORE_POINTER;
-      
-      break;
-      
-    case EnterNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("enter notify:\t\twindow: %ld  detail: %d subwin: %ld",
-                          xevent->xcrossing.window,
-                          xevent->xcrossing.detail,
-                          xevent->xcrossing.subwindow));
-      
-      /* Tell XInput stuff about it if appropriate */
-      if (window_private &&
-         !GDK_DRAWABLE_DESTROYED (window) &&
-         (window_private->extension_events != 0) &&
-         gdk_input_vtable.enter_event)
-       gdk_input_vtable.enter_event (&xevent->xcrossing, window);
-      
-      event->crossing.type = GDK_ENTER_NOTIFY;
-      event->crossing.window = window;
-      
-      /* If the subwindow field of the XEvent is non-NULL, then
-       *  lookup the corresponding GdkWindow.
-       */
-      if (xevent->xcrossing.subwindow != None)
-       event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow);
-      else
-       event->crossing.subwindow = NULL;
-      
-      event->crossing.time = xevent->xcrossing.time;
-      event->crossing.x = xevent->xcrossing.x;
-      event->crossing.y = xevent->xcrossing.y;
-      event->crossing.x_root = xevent->xcrossing.x_root;
-      event->crossing.y_root = xevent->xcrossing.y_root;
-      
-      /* Translate the crossing mode into Gdk terms.
-       */
-      switch (xevent->xcrossing.mode)
-       {
-       case NotifyNormal:
-         event->crossing.mode = GDK_CROSSING_NORMAL;
-         break;
-       case NotifyGrab:
-         event->crossing.mode = GDK_CROSSING_GRAB;
-         break;
-       case NotifyUngrab:
-         event->crossing.mode = GDK_CROSSING_UNGRAB;
-         break;
-       };
-      
-      /* Translate the crossing detail into Gdk terms.
-       */
-      switch (xevent->xcrossing.detail)
-       {
-       case NotifyInferior:
-         event->crossing.detail = GDK_NOTIFY_INFERIOR;
-         break;
-       case NotifyAncestor:
-         event->crossing.detail = GDK_NOTIFY_ANCESTOR;
-         break;
-       case NotifyVirtual:
-         event->crossing.detail = GDK_NOTIFY_VIRTUAL;
-         break;
-       case NotifyNonlinear:
-         event->crossing.detail = GDK_NOTIFY_NONLINEAR;
-         break;
-       case NotifyNonlinearVirtual:
-         event->crossing.detail = GDK_NOTIFY_NONLINEAR_VIRTUAL;
-         break;
-       default:
-         event->crossing.detail = GDK_NOTIFY_UNKNOWN;
-         break;
-       }
-      
-      event->crossing.focus = xevent->xcrossing.focus;
-      event->crossing.state = xevent->xcrossing.state;
-  
-      break;
-      
-    case LeaveNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS, 
-               g_message ("leave notify:\t\twindow: %ld  detail: %d subwin: %ld",
-                          xevent->xcrossing.window,
-                          xevent->xcrossing.detail, xevent->xcrossing.subwindow));
-      
-      event->crossing.type = GDK_LEAVE_NOTIFY;
-      event->crossing.window = window;
-      
-      /* If the subwindow field of the XEvent is non-NULL, then
-       *  lookup the corresponding GdkWindow.
-       */
-      if (xevent->xcrossing.subwindow != None)
-       event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow);
-      else
-       event->crossing.subwindow = NULL;
-      
-      event->crossing.time = xevent->xcrossing.time;
-      event->crossing.x = xevent->xcrossing.x;
-      event->crossing.y = xevent->xcrossing.y;
-      event->crossing.x_root = xevent->xcrossing.x_root;
-      event->crossing.y_root = xevent->xcrossing.y_root;
-      
-      /* Translate the crossing mode into Gdk terms.
-       */
-      switch (xevent->xcrossing.mode)
-       {
-       case NotifyNormal:
-         event->crossing.mode = GDK_CROSSING_NORMAL;
-         break;
-       case NotifyGrab:
-         event->crossing.mode = GDK_CROSSING_GRAB;
-         break;
-       case NotifyUngrab:
-         event->crossing.mode = GDK_CROSSING_UNGRAB;
-         break;
-       };
-      
-      /* Translate the crossing detail into Gdk terms.
-       */
-      switch (xevent->xcrossing.detail)
-       {
-       case NotifyInferior:
-         event->crossing.detail = GDK_NOTIFY_INFERIOR;
-         break;
-       case NotifyAncestor:
-         event->crossing.detail = GDK_NOTIFY_ANCESTOR;
-         break;
-       case NotifyVirtual:
-         event->crossing.detail = GDK_NOTIFY_VIRTUAL;
-         break;
-       case NotifyNonlinear:
-         event->crossing.detail = GDK_NOTIFY_NONLINEAR;
-         break;
-       case NotifyNonlinearVirtual:
-         event->crossing.detail = GDK_NOTIFY_NONLINEAR_VIRTUAL;
-         break;
-       default:
-         event->crossing.detail = GDK_NOTIFY_UNKNOWN;
-         break;
-       }
-      
-      event->crossing.focus = xevent->xcrossing.focus;
-      event->crossing.state = xevent->xcrossing.state;
-      
-      break;
-      
-    case FocusIn:
-    case FocusOut:
-      /* We only care about focus events that indicate that _this_
-       * window (not a ancestor or child) got or lost the focus
-       */
-      switch (xevent->xfocus.detail)
-       {
-       case NotifyAncestor:
-       case NotifyInferior:
-       case NotifyNonlinear:
-         /* Print debugging info.
-          */
-         GDK_NOTE (EVENTS,
-                   g_message ("focus %s:\t\twindow: %ld",
-                              (xevent->xany.type == FocusIn) ? "in" : "out",
-                              xevent->xfocus.window));
-         
-         /* gdk_keyboard_grab() causes following events. These events confuse
-          * the XIM focus, so ignore them.
-          */
-         if (xevent->xfocus.mode == NotifyGrab ||
-             xevent->xfocus.mode == NotifyUngrab)
-           break;
-         
-         event->focus_change.type = GDK_FOCUS_CHANGE;
-         event->focus_change.window = window;
-         event->focus_change.in = (xevent->xany.type == FocusIn);
-
-         break;
-       default:
-         return_val = FALSE;
-       }
-      break;
-      
-    case KeymapNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("keymap notify"));
-
-      /* Not currently handled */
-      return_val = FALSE;
-      break;
-      
-    case Expose:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("expose:\t\twindow: %ld  %d  x,y: %d %d  w,h: %d %d%s",
-                          xevent->xexpose.window, xevent->xexpose.count,
-                          xevent->xexpose.x, xevent->xexpose.y,
-                          xevent->xexpose.width, xevent->xexpose.height,
-                          event->any.send_event ? " (send)" : ""));
-      gdk_compress_exposures (xevent, window);
-      
-      event->expose.type = GDK_EXPOSE;
-      event->expose.window = window;
-      event->expose.area.x = xevent->xexpose.x;
-      event->expose.area.y = xevent->xexpose.y;
-      event->expose.area.width = xevent->xexpose.width;
-      event->expose.area.height = xevent->xexpose.height;
-      event->expose.count = xevent->xexpose.count;
-      
-      break;
-      
-    case GraphicsExpose:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("graphics expose:\tdrawable: %ld",
-                          xevent->xgraphicsexpose.drawable));
-      
-      event->expose.type = GDK_EXPOSE;
-      event->expose.window = window;
-      event->expose.area.x = xevent->xgraphicsexpose.x;
-      event->expose.area.y = xevent->xgraphicsexpose.y;
-      event->expose.area.width = xevent->xgraphicsexpose.width;
-      event->expose.area.height = xevent->xgraphicsexpose.height;
-      event->expose.count = xevent->xexpose.count;
-      
-      break;
-      
-    case NoExpose:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("no expose:\t\tdrawable: %ld",
-                          xevent->xnoexpose.drawable));
-      
-      event->no_expose.type = GDK_NO_EXPOSE;
-      event->no_expose.window = window;
-      
-      break;
-      
-    case VisibilityNotify:
-      /* Print debugging info.
-       */
-#ifdef G_ENABLE_DEBUG
-      if (gdk_debug_flags & GDK_DEBUG_EVENTS)
-       switch (xevent->xvisibility.state)
-         {
-         case VisibilityFullyObscured:
-           g_message ("visibility notify:\twindow: %ld  none",
-                      xevent->xvisibility.window);
-           break;
-         case VisibilityPartiallyObscured:
-           g_message ("visibility notify:\twindow: %ld  partial",
-                      xevent->xvisibility.window);
-           break;
-         case VisibilityUnobscured:
-           g_message ("visibility notify:\twindow: %ld  full",
-                      xevent->xvisibility.window);
-           break;
-         }
-#endif /* G_ENABLE_DEBUG */
-      
-      event->visibility.type = GDK_VISIBILITY_NOTIFY;
-      event->visibility.window = window;
-      
-      switch (xevent->xvisibility.state)
-       {
-       case VisibilityFullyObscured:
-         event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
-         break;
-         
-       case VisibilityPartiallyObscured:
-         event->visibility.state = GDK_VISIBILITY_PARTIAL;
-         break;
-         
-       case VisibilityUnobscured:
-         event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
-         break;
-       }
-      
-      break;
-      
-    case CreateNotify:
-      GDK_NOTE (EVENTS,
-               g_message ("create notify:\twindow: %ld  x,y: %d %d     w,h: %d %d  b-w: %d  parent: %ld         ovr: %d",
-                          xevent->xcreatewindow.window,
-                          xevent->xcreatewindow.x,
-                          xevent->xcreatewindow.y,
-                          xevent->xcreatewindow.width,
-                          xevent->xcreatewindow.height,
-                          xevent->xcreatewindow.border_width,
-                          xevent->xcreatewindow.parent,
-                          xevent->xcreatewindow.override_redirect));
-      /* not really handled */
-      break;
-      
-    case DestroyNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("destroy notify:\twindow: %ld",
-                          xevent->xdestroywindow.window));
-      
-      event->any.type = GDK_DESTROY;
-      event->any.window = window;
-      
-      return_val = window_private && !GDK_DRAWABLE_DESTROYED (window);
-      
-      if (window && GDK_DRAWABLE_XID (window) != GDK_ROOT_WINDOW())
-       gdk_window_destroy_notify (window);
-      break;
-      
-    case UnmapNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("unmap notify:\t\twindow: %ld",
-                          xevent->xmap.window));
-      
-      event->any.type = GDK_UNMAP;
-      event->any.window = window;
-      
-      if (gdk_xgrab_window == window_private)
-       gdk_xgrab_window = NULL;
-      
-      break;
-      
-    case MapNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("map notify:\t\twindow: %ld",
-                          xevent->xmap.window));
-      
-      event->any.type = GDK_MAP;
-      event->any.window = window;
-      
-      break;
-      
-    case ReparentNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("reparent notify:\twindow: %ld  x,y: %d %d  parent: %ld      ovr: %d",
-                          xevent->xreparent.window,
-                          xevent->xreparent.x,
-                          xevent->xreparent.y,
-                          xevent->xreparent.parent,
-                          xevent->xreparent.override_redirect));
-
-      /* Not currently handled */
-      return_val = FALSE;
-      break;
-      
-    case ConfigureNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("configure notify:\twindow: %ld  x,y: %d %d  w,h: %d %d  b-w: %d  above: %ld  ovr: %d%s",
-                          xevent->xconfigure.window,
-                          xevent->xconfigure.x,
-                          xevent->xconfigure.y,
-                          xevent->xconfigure.width,
-                          xevent->xconfigure.height,
-                          xevent->xconfigure.border_width,
-                          xevent->xconfigure.above,
-                          xevent->xconfigure.override_redirect,
-                          !window
-                          ? " (discarding)"
-                          : GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD
-                          ? " (discarding child)"
-                          : ""));
-      if (window &&
-         !GDK_DRAWABLE_DESTROYED (window) &&
-         (window_private->extension_events != 0) &&
-         gdk_input_vtable.configure_event)
-       gdk_input_vtable.configure_event (&xevent->xconfigure, window);
-
-      if (!window || GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD)
-       return_val = FALSE;
-      else
-       {
-         event->configure.type = GDK_CONFIGURE;
-         event->configure.window = window;
-         event->configure.width = xevent->xconfigure.width;
-         event->configure.height = xevent->xconfigure.height;
-         
-         if (!xevent->xconfigure.x &&
-             !xevent->xconfigure.y &&
-             !GDK_DRAWABLE_DESTROYED (window))
-           {
-             gint tx = 0;
-             gint ty = 0;
-             Window child_window = 0;
-
-             gdk_error_trap_push ();
-             if (XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window),
-                                        GDK_DRAWABLE_XID (window),
-                                        gdk_root_window,
-                                        0, 0,
-                                        &tx, &ty,
-                                        &child_window))
-               {
-                 if (!gdk_error_trap_pop ())
-                   {
-                     event->configure.x = tx;
-                     event->configure.y = ty;
-                   }
-               }
-             else
-               gdk_error_trap_pop ();
-           }
-         else
-           {
-             event->configure.x = xevent->xconfigure.x;
-             event->configure.y = xevent->xconfigure.y;
-           }
-         window_private->x = event->configure.x;
-         window_private->y = event->configure.y;
-         window_private->drawable.width = xevent->xconfigure.width;
-         window_private->drawable.height = xevent->xconfigure.height;
-         if (window_private->resize_count > 1)
-           window_private->resize_count -= 1;
-       }
-      break;
-      
-    case PropertyNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               gchar *atom = gdk_atom_name (xevent->xproperty.atom);
-               g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
-                          xevent->xproperty.window,
-                          xevent->xproperty.atom,
-                          atom ? "\"" : "",
-                          atom ? atom : "unknown",
-                          atom ? "\"" : "");
-               g_free (atom);
-               );
-      
-      event->property.type = GDK_PROPERTY_NOTIFY;
-      event->property.window = window;
-      event->property.atom = xevent->xproperty.atom;
-      event->property.time = xevent->xproperty.time;
-      event->property.state = xevent->xproperty.state;
-      
-      break;
-      
-    case SelectionClear:
-      GDK_NOTE (EVENTS,
-               g_message ("selection clear:\twindow: %ld",
-                          xevent->xproperty.window));
-      
-      event->selection.type = GDK_SELECTION_CLEAR;
-      event->selection.window = window;
-      event->selection.selection = xevent->xselectionclear.selection;
-      event->selection.time = xevent->xselectionclear.time;
-      
-      break;
-      
-    case SelectionRequest:
-      GDK_NOTE (EVENTS,
-               g_message ("selection request:\twindow: %ld",
-                          xevent->xproperty.window));
-      
-      event->selection.type = GDK_SELECTION_REQUEST;
-      event->selection.window = window;
-      event->selection.selection = xevent->xselectionrequest.selection;
-      event->selection.target = xevent->xselectionrequest.target;
-      event->selection.property = xevent->xselectionrequest.property;
-      event->selection.requestor = xevent->xselectionrequest.requestor;
-      event->selection.time = xevent->xselectionrequest.time;
-      
-      break;
-      
-    case SelectionNotify:
-      GDK_NOTE (EVENTS,
-               g_message ("selection notify:\twindow: %ld",
-                          xevent->xproperty.window));
-      
-      
-      event->selection.type = GDK_SELECTION_NOTIFY;
-      event->selection.window = window;
-      event->selection.selection = xevent->xselection.selection;
-      event->selection.target = xevent->xselection.target;
-      event->selection.property = xevent->xselection.property;
-      event->selection.time = xevent->xselection.time;
-      
-      break;
-      
-    case ColormapNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("colormap notify:\twindow: %ld",
-                          xevent->xcolormap.window));
-      
-      /* Not currently handled */
-      return_val = FALSE;
-      break;
-      
-    case ClientMessage:
-      {
-       GList *tmp_list;
-       GdkFilterReturn result = GDK_FILTER_CONTINUE;
-
-       /* Print debugging info.
-        */
-       GDK_NOTE (EVENTS,
-                 g_message ("client message:\twindow: %ld",
-                            xevent->xclient.window));
-       
-       tmp_list = client_filters;
-       while (tmp_list)
-         {
-           GdkClientFilter *filter = tmp_list->data;
-           if (filter->type == xevent->xclient.message_type)
-             {
-               result = (*filter->function) (xevent, event, filter->data);
-               break;
-             }
-           
-           tmp_list = tmp_list->next;
-         }
-
-       switch (result)
-         {
-         case GDK_FILTER_REMOVE:
-           return_val = FALSE;
-           break;
-         case GDK_FILTER_TRANSLATE:
-           return_val = TRUE;
-           break;
-         case GDK_FILTER_CONTINUE:
-           /* Send unknown ClientMessage's on to Gtk for it to use */
-           event->client.type = GDK_CLIENT_EVENT;
-           event->client.window = window;
-           event->client.message_type = xevent->xclient.message_type;
-           event->client.data_format = xevent->xclient.format;
-           memcpy(&event->client.data, &xevent->xclient.data,
-                  sizeof(event->client.data));
-         }
-      }
-      
-      break;
-      
-    case MappingNotify:
-      /* Print debugging info.
-       */
-      GDK_NOTE (EVENTS,
-               g_message ("mapping notify"));
-      
-      /* Let XLib know that there is a new keyboard mapping.
-       */
-      XRefreshKeyboardMapping (&xevent->xmapping);
-      return_val = FALSE;
-      break;
-      
-    default:
-      /* something else - (e.g., a Xinput event) */
-      
-      if (window_private &&
-         !window_private->drawable.destroyed &&
-         (window_private->extension_events != 0) &&
-         gdk_input_vtable.other_event)
-       return_val = gdk_input_vtable.other_event(event, xevent, window);
-      else
-       return_val = FALSE;
-      
-      break;
-    }
-  
-  if (return_val)
-    {
-      if (event->any.window)
-       gdk_window_ref (event->any.window);
-      if (((event->any.type == GDK_ENTER_NOTIFY) ||
-          (event->any.type == GDK_LEAVE_NOTIFY)) &&
-         (event->crossing.subwindow != NULL))
-       gdk_window_ref (event->crossing.subwindow);
-    }
-  else
-    {
-      /* Mark this event as having no resources to be freed */
-      event->any.window = NULL;
-      event->any.type = GDK_NOTHING;
-    }
-  
-  if (window)
-    gdk_window_unref (window);
-  
-  return return_val;
-}
-
-GdkFilterReturn
-gdk_wm_protocols_filter (GdkXEvent *xev,
-                        GdkEvent  *event,
-                        gpointer data)
-{
-  XEvent *xevent = (XEvent *)xev;
-
-  if ((Atom) xevent->xclient.data.l[0] == gdk_wm_delete_window)
-    {
-  /* The delete window request specifies a window
-   *  to delete. We don't actually destroy the
-   *  window because "it is only a request". (The
-   *  window might contain vital data that the
-   *  program does not want destroyed). Instead
-   *  the event is passed along to the program,
-   *  which should then destroy the window.
-   */
-      GDK_NOTE (EVENTS,
-               g_message ("delete window:\t\twindow: %ld",
-                          xevent->xclient.window));
-      
-      event->any.type = GDK_DELETE;
-
-      return GDK_FILTER_TRANSLATE;
-    }
-  else if ((Atom) xevent->xclient.data.l[0] == gdk_wm_take_focus)
-    {
-    }
-
-  return GDK_FILTER_REMOVE;
-}
-
-#if 0
-static Bool
-gdk_event_get_type (Display  *display,
-                   XEvent   *xevent,
-                   XPointer  arg)
-{
-  GdkEvent event;
-  GdkPredicate *pred;
-  
-  if (gdk_event_translate (&event, xevent))
-    {
-      pred = (GdkPredicate*) arg;
-      return (* pred->func) (&event, pred->data);
-    }
-  
-  return FALSE;
-}
-#endif
-
-static void
-gdk_events_queue (void)
-{
-  GList *node;
-  GdkEvent *event;
-  XEvent xevent;
-
-  while (!gdk_event_queue_find_first() && XPending (gdk_display))
-    {
-#ifdef USE_XIM
-      Window w = None;
-      
-      XNextEvent (gdk_display, &xevent);
-      if (gdk_xim_window)
-       switch (xevent.type)
-         {
-         case KeyPress:
-         case KeyRelease:
-         case ButtonPress:
-         case ButtonRelease:
-           w = GDK_WINDOW_XWINDOW (gdk_xim_window);
-           break;
-         }
-      
-      if (XFilterEvent (&xevent, w))
-       continue;
-#else
-      XNextEvent (gdk_display, &xevent);
-#endif
-      
-      event = gdk_event_new ();
-      
-      event->any.type = GDK_NOTHING;
-      event->any.window = NULL;
-      event->any.send_event = xevent.xany.send_event ? TRUE : FALSE;
-
-      ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
-
-      gdk_event_queue_append (event);
-      node = queued_tail;
-
-      if (gdk_event_translate (event, &xevent))
-       {
-         ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
-       }
-      else
-       {
-         gdk_event_queue_remove_link (node);
-         g_list_free_1 (node);
-         gdk_event_free (event);
-       }
-    }
-}
-
-static gboolean  
-gdk_event_prepare (gpointer  source_data, 
-                  GTimeVal *current_time,
-                  gint     *timeout,
-                  gpointer  user_data)
-{
-  gboolean retval;
-  
-  GDK_THREADS_ENTER ();
-
-  *timeout = -1;
-
-  retval = (gdk_event_queue_find_first () != NULL) || XPending (gdk_display);
-
-  GDK_THREADS_LEAVE ();
-
-  return retval;
-}
-
-static gboolean  
-gdk_event_check (gpointer  source_data,
-                GTimeVal *current_time,
-                gpointer  user_data)
-{
-  gboolean retval;
-  
-  GDK_THREADS_ENTER ();
-
-  if (event_poll_fd.revents & G_IO_IN)
-    retval = (gdk_event_queue_find_first () != NULL) || XPending (gdk_display);
-  else
-    retval = FALSE;
-
-  GDK_THREADS_LEAVE ();
-
-  return retval;
-}
-
-static GdkEvent*
+GdkEvent*
 gdk_event_unqueue (void)
 {
   GdkEvent *event = NULL;
@@ -2082,32 +579,7 @@ gdk_event_unqueue (void)
   return event;
 }
 
-static gboolean  
-gdk_event_dispatch (gpointer  source_data,
-                   GTimeVal *current_time,
-                   gpointer  user_data)
-{
-  GdkEvent *event;
-  GDK_THREADS_ENTER ();
-
-  gdk_events_queue();
-  event = gdk_event_unqueue();
-
-  if (event)
-    {
-      if (event_func)
-       (*event_func) (event, event_data);
-      
-      gdk_event_free (event);
-    }
-  
-  GDK_THREADS_LEAVE ();
-
-  return TRUE;
-}
-
-static void
+void
 gdk_synthesize_click (GdkEvent *event,
                      gint      nclicks)
 {
@@ -2121,135 +593,42 @@ gdk_synthesize_click (GdkEvent *event,
   gdk_event_put (&temp_event);
 }
 
-/* Sends a ClientMessage to all toplevel client windows */
-gboolean
-gdk_event_send_client_message (GdkEvent *event, guint32 xid)
-{
-  XEvent sev;
-  
-  g_return_val_if_fail(event != NULL, FALSE);
-  
-  /* Set up our event to send, with the exception of its target window */
-  sev.xclient.type = ClientMessage;
-  sev.xclient.display = gdk_display;
-  sev.xclient.format = event->client.data_format;
-  sev.xclient.window = xid;
-  memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data));
-  sev.xclient.message_type = event->client.message_type;
-  
-  return gdk_send_xevent (xid, False, NoEventMask, &sev);
-}
-
-/* Sends a ClientMessage to all toplevel client windows */
-gboolean
-gdk_event_send_client_message_to_all_recurse (XEvent  *xev, 
-                                             guint32  xid,
-                                             guint    level)
+void
+gdk_event_button_generate (GdkEvent *event)
 {
-  static GdkAtom wm_state_atom = GDK_NONE;
-  Atom type = None;
-  int format;
-  unsigned long nitems, after;
-  unsigned char *data;
-  Window *ret_children, ret_root, ret_parent;
-  unsigned int ret_nchildren;
-  gint old_warnings = gdk_error_warnings;
-  gboolean send = FALSE;
-  gboolean found = FALSE;
-  int i;
-
-  if (!wm_state_atom)
-    wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE);
-
-  gdk_error_warnings = FALSE;
-  gdk_error_code = 0;
-  XGetWindowProperty (gdk_display, xid, wm_state_atom, 0, 0, False, AnyPropertyType,
-                     &type, &format, &nitems, &after, &data);
-
-  if (gdk_error_code)
+  if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
+      (event->button.window == button_window[1]) &&
+      (event->button.button == button_number[1]))
     {
-      gdk_error_warnings = old_warnings;
-
-      return FALSE;
+      gdk_synthesize_click (event, 3);
+      
+      button_click_time[1] = 0;
+      button_click_time[0] = 0;
+      button_window[1] = NULL;
+      button_window[0] = 0;
+      button_number[1] = -1;
+      button_number[0] = -1;
     }
-
-  if (type)
+  else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
+          (event->button.window == button_window[0]) &&
+          (event->button.button == button_number[0]))
     {
-      send = TRUE;
-      XFree (data);
+      gdk_synthesize_click (event, 2);
+      
+      button_click_time[1] = button_click_time[0];
+      button_click_time[0] = event->button.time;
+      button_window[1] = button_window[0];
+      button_window[0] = event->button.window;
+      button_number[1] = button_number[0];
+      button_number[0] = event->button.button;
     }
   else
     {
-      /* OK, we're all set, now let's find some windows to send this to */
-      if (XQueryTree (gdk_display, xid, &ret_root, &ret_parent,
-                     &ret_children, &ret_nchildren) != True ||
-         gdk_error_code)
-       {
-         gdk_error_warnings = old_warnings;
-
-         return FALSE;
-       }
-
-      for(i = 0; i < ret_nchildren; i++)
-       if (gdk_event_send_client_message_to_all_recurse (xev, ret_children[i], level + 1))
-         found = TRUE;
-
-      XFree (ret_children);
-    }
-
-  if (send || (!found && (level == 1)))
-    {
-      xev->xclient.window = xid;
-      gdk_send_xevent (xid, False, NoEventMask, xev);
+      button_click_time[1] = 0;
+      button_click_time[0] = event->button.time;
+      button_window[1] = NULL;
+      button_window[0] = event->button.window;
+      button_number[1] = -1;
+      button_number[0] = event->button.button;
     }
-
-  gdk_error_warnings = old_warnings;
-
-  return (send || found);
-}
-
-void
-gdk_event_send_clientmessage_toall (GdkEvent *event)
-{
-  XEvent sev;
-  gint old_warnings = gdk_error_warnings;
-
-  g_return_if_fail(event != NULL);
-  
-  /* Set up our event to send, with the exception of its target window */
-  sev.xclient.type = ClientMessage;
-  sev.xclient.display = gdk_display;
-  sev.xclient.format = event->client.data_format;
-  memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data));
-  sev.xclient.message_type = event->client.message_type;
-
-  gdk_event_send_client_message_to_all_recurse(&sev, gdk_root_window, 0);
-
-  gdk_error_warnings = old_warnings;
 }
-
-/*
- *--------------------------------------------------------------
- * gdk_flush
- *
- *   Flushes the Xlib output buffer and then waits
- *   until all requests have been received and processed
- *   by the X server. The only real use for this function
- *   is in dealing with XShm.
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-void
-gdk_flush (void)
-{
-  XSync (gdk_display, False);
-}
-
-
index a3a3502fba28590e4ef3434850088c0feee6d242..9c051383ef1886debf46e4c4a77ad157c1976c2a 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <X11/Xlib.h>
-#include <X11/Xos.h>
 #include "gdkfont.h"
 #include "gdkprivate.h"
 
-static GHashTable *font_name_hash = NULL;
-static GHashTable *fontset_name_hash = NULL;
-
-static void
-gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
-{
-  GdkFontPrivate *private = (GdkFontPrivate *)font;
-  GHashTable **hashp = (type == GDK_FONT_FONT) ?
-    &font_name_hash : &fontset_name_hash;
-
-  if (!*hashp)
-    *hashp = g_hash_table_new (g_str_hash, g_str_equal);
-
-  private->names = g_slist_prepend (private->names, g_strdup (font_name));
-  g_hash_table_insert (*hashp, private->names->data, font);
-}
-
-static void
-gdk_font_hash_remove (GdkFontType type, GdkFont *font)
-{
-  GdkFontPrivate *private = (GdkFontPrivate *)font;
-  GSList *tmp_list;
-  GHashTable *hash = (type == GDK_FONT_FONT) ?
-    font_name_hash : fontset_name_hash;
-
-  tmp_list = private->names;
-  while (tmp_list)
-    {
-      g_hash_table_remove (hash, tmp_list->data);
-      g_free (tmp_list->data);
-      
-      tmp_list = tmp_list->next;
-    }
-
-  g_slist_free (private->names);
-  private->names = NULL;
-}
-
-static GdkFont *
-gdk_font_hash_lookup (GdkFontType type, const gchar *font_name)
-{
-  GdkFont *result;
-  GHashTable *hash = (type == GDK_FONT_FONT) ?
-    font_name_hash : fontset_name_hash;
-
-  if (!hash)
-    return NULL;
-  else
-    {
-      result = g_hash_table_lookup (hash, font_name);
-      if (result)
-       gdk_font_ref (result);
-      
-      return result;
-    }
-}
-
-GdkFont*
-gdk_font_load (const gchar *font_name)
-{
-  GdkFont *font;
-  GdkFontPrivate *private;
-  XFontStruct *xfont;
-
-  g_return_val_if_fail (font_name != NULL, NULL);
-
-  font = gdk_font_hash_lookup (GDK_FONT_FONT, font_name);
-  if (font)
-    return font;
-
-  xfont = XLoadQueryFont (gdk_display, font_name);
-  if (xfont == NULL)
-    return NULL;
-
-  font = gdk_font_lookup (xfont->fid);
-  if (font != NULL)
-    {
-      private = (GdkFontPrivate *) font;
-      if (xfont != private->xfont)
-       XFreeFont (gdk_display, xfont);
-
-      gdk_font_ref (font);
-    }
-  else
-    {
-      private = g_new (GdkFontPrivate, 1);
-      private->xdisplay = gdk_display;
-      private->xfont = xfont;
-      private->ref_count = 1;
-      private->names = NULL;
-      font = (GdkFont*) private;
-      font->type = GDK_FONT_FONT;
-      font->ascent =  xfont->ascent;
-      font->descent = xfont->descent;
-
-      gdk_xid_table_insert (&xfont->fid, font);
-    }
-
-  gdk_font_hash_insert (GDK_FONT_FONT, font, font_name);
-
-  return font;
-}
-
-GdkFont*
-gdk_fontset_load (gchar *fontset_name)
-{
-  GdkFont *font;
-  GdkFontPrivate *private;
-  XFontSet fontset;
-  gint  missing_charset_count;
-  gchar **missing_charset_list;
-  gchar *def_string;
-
-  font = gdk_font_hash_lookup (GDK_FONT_FONTSET, fontset_name);
-  if (font)
-    return font;
-
-  private = g_new (GdkFontPrivate, 1);
-  font = (GdkFont*) private;
-
-  private->xdisplay = gdk_display;
-  fontset = XCreateFontSet (gdk_display, fontset_name,
-                           &missing_charset_list, &missing_charset_count,
-                           &def_string);
-
-  if (missing_charset_count)
-    {
-      gint i;
-      g_warning ("Missing charsets in FontSet creation\n");
-      for (i=0;i<missing_charset_count;i++)
-       g_warning ("    %s\n", missing_charset_list[i]);
-      XFreeStringList (missing_charset_list);
-    }
-
-  private->ref_count = 1;
-
-  if (!fontset)
-    {
-      g_free (font);
-      return NULL;
-    }
-  else
-    {
-      gint num_fonts;
-      gint i;
-      XFontStruct **font_structs;
-      gchar **font_names;
-      
-      private->xfont = fontset;
-      font->type = GDK_FONT_FONTSET;
-      num_fonts = XFontsOfFontSet (fontset, &font_structs, &font_names);
-
-      font->ascent = font->descent = 0;
-      
-      for (i = 0; i < num_fonts; i++)
-       {
-         font->ascent = MAX (font->ascent, font_structs[i]->ascent);
-         font->descent = MAX (font->descent, font_structs[i]->descent);
-       }
-
-      private->names = NULL;
-      gdk_font_hash_insert (GDK_FONT_FONTSET, font, fontset_name);
-      
-      return font;
-    }
-}
-
 GdkFont*
 gdk_font_ref (GdkFont *font)
 {
@@ -220,304 +50,35 @@ gdk_font_unref (GdkFont *font)
 
   private->ref_count -= 1;
   if (private->ref_count == 0)
-    {
-      gdk_font_hash_remove (font->type, font);
-      
-      switch (font->type)
-       {
-       case GDK_FONT_FONT:
-         gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
-         XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
-         break;
-       case GDK_FONT_FONTSET:
-         XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
-         break;
-       default:
-         g_error ("unknown font type.");
-         break;
-       }
-      g_free (font);
-    }
-}
-
-gint
-gdk_font_id (const GdkFont *font)
-{
-  const GdkFontPrivate *font_private;
-
-  g_return_val_if_fail (font != NULL, 0);
-
-  font_private = (const GdkFontPrivate*) font;
-
-  if (font->type == GDK_FONT_FONT)
-    {
-      return ((XFontStruct *) font_private->xfont)->fid;
-    }
-  else
-    {
-      return 0;
-    }
-}
-
-gint
-gdk_font_equal (const GdkFont *fonta,
-                const GdkFont *fontb)
-{
-  const GdkFontPrivate *privatea;
-  const GdkFontPrivate *privateb;
-
-  g_return_val_if_fail (fonta != NULL, FALSE);
-  g_return_val_if_fail (fontb != NULL, FALSE);
-
-  privatea = (const GdkFontPrivate*) fonta;
-  privateb = (const GdkFontPrivate*) fontb;
-
-  if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)
-    {
-      return (((XFontStruct *) privatea->xfont)->fid ==
-             ((XFontStruct *) privateb->xfont)->fid);
-    }
-  else if (fonta->type == GDK_FONT_FONTSET && fontb->type == GDK_FONT_FONTSET)
-    {
-      gchar *namea, *nameb;
-
-      namea = XBaseFontNameListOfFontSet((XFontSet) privatea->xfont);
-      nameb = XBaseFontNameListOfFontSet((XFontSet) privateb->xfont);
-      
-      return (strcmp(namea, nameb) == 0);
-    }
-  else
-    /* fontset != font */
-    return 0;
+    _gdk_font_destroy (font);
 }
 
 gint
 gdk_string_width (GdkFont     *font,
                  const gchar *string)
 {
-  GdkFontPrivate *font_private;
-  gint width;
-  XFontStruct *xfont;
-  XFontSet fontset;
-
   g_return_val_if_fail (font != NULL, -1);
   g_return_val_if_fail (string != NULL, -1);
 
-  font_private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) font_private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         width = XTextWidth (xfont, string, strlen (string));
-       }
-      else
-       {
-         width = XTextWidth16 (xfont, (XChar2b *) string, strlen (string) / 2);
-       }
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) font_private->xfont;
-      width = XmbTextEscapement (fontset, string, strlen(string));
-      break;
-    default:
-      width = 0;
-    }
-
-  return width;
-}
-
-gint
-gdk_text_width (GdkFont      *font,
-               const gchar  *text,
-               gint          text_length)
-{
-  GdkFontPrivate *private;
-  gint width;
-  XFontStruct *xfont;
-  XFontSet fontset;
-
-  g_return_val_if_fail (font != NULL, -1);
-  g_return_val_if_fail (text != NULL, -1);
-
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         width = XTextWidth (xfont, text, text_length);
-       }
-      else
-       {
-         width = XTextWidth16 (xfont, (XChar2b *) text, text_length / 2);
-       }
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      width = XmbTextEscapement (fontset, text, text_length);
-      break;
-    default:
-      width = 0;
-    }
-  return width;
+  return gdk_text_width (font, string, _gdk_font_strlen (font, string));
 }
 
-gint
-gdk_text_width_wc (GdkFont       *font,
-                  const GdkWChar *text,
-                  gint            text_length)
-{
-  GdkFontPrivate *private;
-  gint width;
-  XFontStruct *xfont;
-  XFontSet fontset;
-
-  g_return_val_if_fail (font != NULL, -1);
-  g_return_val_if_fail (text != NULL, -1);
-
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-        {
-          gchar *text_8bit;
-          gint i;
-          text_8bit = g_new (gchar, text_length);
-          for (i=0; i<text_length; i++) text_8bit[i] = text[i];
-          width = XTextWidth (xfont, text_8bit, text_length);
-          g_free (text_8bit);
-        }
-      else
-        {
-          width = 0;
-        }
-      break;
-    case GDK_FONT_FONTSET:
-      if (sizeof(GdkWChar) == sizeof(wchar_t))
-       {
-         fontset = (XFontSet) private->xfont;
-         width = XwcTextEscapement (fontset, (wchar_t *)text, text_length);
-       }
-      else
-       {
-         wchar_t *text_wchar;
-         gint i;
-         fontset = (XFontSet) private->xfont;
-         text_wchar = g_new(wchar_t, text_length);
-         for (i=0; i<text_length; i++) text_wchar[i] = text[i];
-         width = XwcTextEscapement (fontset, text_wchar, text_length);
-         g_free (text_wchar);
-       }
-      break;
-    default:
-      width = 0;
-    }
-  return width;
-}
-
-/* Problem: What if a character is a 16 bits character ?? */
 gint
 gdk_char_width (GdkFont *font,
                gchar    character)
 {
-  GdkFontPrivate *private;
-  XCharStruct *chars;
-  gint width;
-  guint ch = character & 0xff;  /* get rid of sign-extension */
-  XFontStruct *xfont;
-  XFontSet fontset;
-
   g_return_val_if_fail (font != NULL, -1);
 
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      /* only 8 bits characters are considered here */
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) &&
-         (xfont->max_byte1 == 0) &&
-         (ch >= xfont->min_char_or_byte2) &&
-         (ch <= xfont->max_char_or_byte2))
-       {
-         chars = xfont->per_char;
-         if (chars)
-           width = chars[ch - xfont->min_char_or_byte2].width;
-         else
-           width = xfont->min_bounds.width;
-       }
-      else
-       {
-         width = XTextWidth (xfont, &character, 1);
-       }
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      width = XmbTextEscapement (fontset, &character, 1) ;
-      break;
-    default:
-      width = 0;
-    }
-  return width;
+  return gdk_text_width (font, &character, 1);
 }
 
 gint
 gdk_char_width_wc (GdkFont *font,
                   GdkWChar character)
 {
-  GdkFontPrivate *private;
-  XCharStruct *chars;
-  gint width;
-  guint ch = character & 0xff;  /* get rid of sign-extension */
-  XFontStruct *xfont;
-  XFontSet fontset;
-
   g_return_val_if_fail (font != NULL, -1);
 
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      /* only 8 bits characters are considered here */
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) &&
-          (xfont->max_byte1 == 0) &&
-          (ch >= xfont->min_char_or_byte2) &&
-          (ch <= xfont->max_char_or_byte2))
-        {
-          chars = xfont->per_char;
-          if (chars)
-            width = chars[ch - xfont->min_char_or_byte2].width;
-          else
-            width = xfont->min_bounds.width;
-        }
-      else
-        {
-          char ch2 = character;
-          width = XTextWidth (xfont, &ch2, 1);
-        }
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      {
-       wchar_t char_wc = character;
-        width = XwcTextEscapement (fontset, &char_wc, 1) ;
-      }
-      break;
-    default:
-      width = 0;
-    }
-  return width;
+  return gdk_text_width_wc (font, &character, 1);
 }
 
 gint
@@ -527,162 +88,7 @@ gdk_string_measure (GdkFont     *font,
   g_return_val_if_fail (font != NULL, -1);
   g_return_val_if_fail (string != NULL, -1);
 
-  return gdk_text_measure (font, string, strlen (string));
-}
-
-void
-gdk_text_extents (GdkFont     *font,
-                  const gchar *text,
-                  gint         text_length,
-                 gint        *lbearing,
-                 gint        *rbearing,
-                 gint        *width,
-                 gint        *ascent,
-                 gint        *descent)
-{
-  GdkFontPrivate *private;
-  XCharStruct overall;
-  XFontStruct *xfont;
-  XFontSet    fontset;
-  XRectangle  ink, logical;
-  int direction;
-  int font_ascent;
-  int font_descent;
-
-  g_return_if_fail (font != NULL);
-  g_return_if_fail (text != NULL);
-
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         XTextExtents (xfont, text, text_length,
-                       &direction, &font_ascent, &font_descent,
-                       &overall);
-       }
-      else
-       {
-         XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
-                         &direction, &font_ascent, &font_descent,
-                         &overall);
-       }
-      if (lbearing)
-       *lbearing = overall.lbearing;
-      if (rbearing)
-       *rbearing = overall.rbearing;
-      if (width)
-       *width = overall.width;
-      if (ascent)
-       *ascent = overall.ascent;
-      if (descent)
-       *descent = overall.descent;
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      XmbTextExtents (fontset, text, text_length, &ink, &logical);
-      if (lbearing)
-       *lbearing = ink.x;
-      if (rbearing)
-       *rbearing = ink.x + ink.width;
-      if (width)
-       *width = logical.width;
-      if (ascent)
-       *ascent = -ink.y;
-      if (descent)
-       *descent = ink.y + ink.height;
-      break;
-    }
-
-}
-
-void
-gdk_text_extents_wc (GdkFont        *font,
-                    const GdkWChar *text,
-                    gint            text_length,
-                    gint           *lbearing,
-                    gint           *rbearing,
-                    gint           *width,
-                    gint           *ascent,
-                    gint           *descent)
-{
-  GdkFontPrivate *private;
-  XCharStruct overall;
-  XFontStruct *xfont;
-  XFontSet    fontset;
-  XRectangle  ink, logical;
-  int direction;
-  int font_ascent;
-  int font_descent;
-
-  g_return_if_fail (font != NULL);
-  g_return_if_fail (text != NULL);
-
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      {
-       gchar *text_8bit;
-       gint i;
-
-       xfont = (XFontStruct *) private->xfont;
-       g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
-
-       text_8bit = g_new (gchar, text_length);
-       for (i=0; i<text_length; i++) 
-         text_8bit[i] = text[i];
-
-       XTextExtents (xfont, text_8bit, text_length,
-                     &direction, &font_ascent, &font_descent,
-                     &overall);
-       g_free (text_8bit);
-       
-       if (lbearing)
-         *lbearing = overall.lbearing;
-       if (rbearing)
-         *rbearing = overall.rbearing;
-       if (width)
-         *width = overall.width;
-       if (ascent)
-         *ascent = overall.ascent;
-       if (descent)
-         *descent = overall.descent;
-       break;
-      }
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-
-      if (sizeof(GdkWChar) == sizeof(wchar_t))
-       XwcTextExtents (fontset, (wchar_t *)text, text_length, &ink, &logical);
-      else
-       {
-         wchar_t *text_wchar;
-         gint i;
-         
-         text_wchar = g_new (wchar_t, text_length);
-         for (i = 0; i < text_length; i++)
-           text_wchar[i] = text[i];
-         XwcTextExtents (fontset, text_wchar, text_length, &ink, &logical);
-         g_free (text_wchar);
-       }
-      if (lbearing)
-       *lbearing = ink.x;
-      if (rbearing)
-       *rbearing = ink.x + ink.width;
-      if (width)
-       *width = logical.width;
-      if (ascent)
-       *ascent = -ink.y;
-      if (descent)
-       *descent = ink.y + ink.height;
-      break;
-    }
-
+  return gdk_text_measure (font, string, _gdk_font_strlen (font, string));
 }
 
 void
@@ -697,7 +103,7 @@ gdk_string_extents (GdkFont     *font,
   g_return_if_fail (font != NULL);
   g_return_if_fail (string != NULL);
 
-  gdk_text_extents (font, string, strlen (string),
+  gdk_text_extents (font, string, _gdk_font_strlen (font, string),
                    lbearing, rbearing, width, ascent, descent);
 }
 
@@ -707,50 +113,14 @@ gdk_text_measure (GdkFont     *font,
                   const gchar *text,
                   gint         text_length)
 {
-  GdkFontPrivate *private;
-  XCharStruct overall;
-  XFontStruct *xfont;
-  XFontSet    fontset;
-  XRectangle  ink, log;
-  int direction;
-  int font_ascent;
-  int font_descent;
-  gint width;
+  gint rbearing;
 
   g_return_val_if_fail (font != NULL, -1);
   g_return_val_if_fail (text != NULL, -1);
 
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         XTextExtents (xfont, text, text_length,
-                       &direction, &font_ascent, &font_descent,
-                       &overall);
-       }
-      else
-       {
-         XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
-                         &direction, &font_ascent, &font_descent,
-                         &overall);
-       }
-      width = overall.rbearing;
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      XmbTextExtents (fontset, text, text_length, &ink, &log);
-      width = ink.x + ink.width;
-      break;
-    default:
-      width = 0;
-    }
-  return width;
+  gdk_text_extents (font, text, text_length, NULL, &rbearing, NULL, NULL, NULL);
+  return rbearing;
 }
-
 gint
 gdk_char_measure (GdkFont *font,
                   gchar    character)
@@ -767,7 +137,7 @@ gdk_string_height (GdkFont     *font,
   g_return_val_if_fail (font != NULL, -1);
   g_return_val_if_fail (string != NULL, -1);
 
-  return gdk_text_height (font, string, strlen (string));
+  return gdk_text_height (font, string, _gdk_font_strlen (font, string));
 }
 
 gint
@@ -775,48 +145,13 @@ gdk_text_height (GdkFont     *font,
                 const gchar *text,
                 gint         text_length)
 {
-  GdkFontPrivate *private;
-  XCharStruct overall;
-  XFontStruct *xfont;
-  XFontSet    fontset;
-  XRectangle  ink, log;
-  int direction;
-  int font_ascent;
-  int font_descent;
-  gint height;
+  gint ascent, descent;
 
   g_return_val_if_fail (font != NULL, -1);
   g_return_val_if_fail (text != NULL, -1);
 
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         XTextExtents (xfont, text, text_length,
-                       &direction, &font_ascent, &font_descent,
-                       &overall);
-       }
-      else
-       {
-         XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
-                         &direction, &font_ascent, &font_descent,
-                         &overall);
-       }
-      height = overall.ascent + overall.descent;
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      XmbTextExtents (fontset, text, text_length, &ink, &log);
-      height = log.height;
-      break;
-    default:
-      height = 0;
-    }
-  return height;
+  gdk_text_extents (font, text, text_length, NULL, NULL, NULL, &ascent, &descent);
+  return ascent + descent;
 }
 
 gint
index e8772cfe9bb7ba8fbb47528ee5a16daf6cd17c3e..11a6c2852f9e7380b2f4504f21b854763a9c352b 100644 (file)
  */
 
 #include <string.h>
-#include <X11/Xlib.h>
 
 #include "gdkgc.h"
 #include "gdkprivate.h"
-#include "gdkx.h"
 
 GdkGC*
-gdk_gc_new (GdkWindow *window)
+gdk_gc_alloc (void)
 {
-  return gdk_gc_new_with_values (window, NULL, 0);
+  GdkGCPrivate *private;
+
+  private = g_new (GdkGCPrivate, 1);
+  private->ref_count = 1;
+  private->klass = NULL;
+  private->klass = NULL;
+  private->klass_data = NULL;
+
+  return (GdkGC *)private;
 }
 
 GdkGC*
-gdk_gc_new_with_values (GdkWindow      *window,
-                       GdkGCValues     *values,
-                       GdkGCValuesMask  values_mask)
+gdk_gc_new (GdkDrawable *drawable)
 {
-  GdkGC *gc;
-  GdkGCPrivate *private;
-  Window xwindow;
-  XGCValues xvalues;
-  unsigned long xvalues_mask;
-
-  g_return_val_if_fail (window != NULL, NULL);
+  g_return_val_if_fail (drawable != NULL, NULL);
 
-  if (GDK_DRAWABLE_DESTROYED (window))
+  if (GDK_DRAWABLE_DESTROYED (drawable))
     return NULL;
 
-  private = g_new (GdkGCPrivate, 1);
-  gc = (GdkGC*) private;
-
-  xwindow = GDK_DRAWABLE_XID (window);
-  private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
-  private->ref_count = 1;
-
-  xvalues.function = GXcopy;
-  xvalues.fill_style = FillSolid;
-  xvalues.arc_mode = ArcPieSlice;
-  xvalues.subwindow_mode = ClipByChildren;
-  xvalues.graphics_exposures = True;
-  xvalues_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures;
-
-  if (values_mask & GDK_GC_FOREGROUND)
-    {
-      xvalues.foreground = values->foreground.pixel;
-      xvalues_mask |= GCForeground;
-    }
-  if (values_mask & GDK_GC_BACKGROUND)
-    {
-      xvalues.background = values->background.pixel;
-      xvalues_mask |= GCBackground;
-    }
-  if ((values_mask & GDK_GC_FONT) && (values->font->type == GDK_FONT_FONT))
-    {
-      xvalues.font = ((XFontStruct *) ((GdkFontPrivate*) values->font)->xfont)->fid;
-      xvalues_mask |= GCFont;
-    }
-  if (values_mask & GDK_GC_FUNCTION)
-    {
-      switch (values->function)
-       {
-       case GDK_COPY:
-         xvalues.function = GXcopy;
-         break;
-       case GDK_INVERT:
-         xvalues.function = GXinvert;
-         break;
-       case GDK_XOR:
-         xvalues.function = GXxor;
-         break;
-       case GDK_CLEAR:
-         xvalues.function = GXclear;
-         break;
-       case GDK_AND:
-         xvalues.function = GXand;
-         break;
-       case GDK_AND_REVERSE:
-         xvalues.function = GXandReverse;
-         break;
-       case GDK_AND_INVERT:
-         xvalues.function = GXandInverted;
-         break;
-       case GDK_NOOP:
-         xvalues.function = GXnoop;
-         break;
-       case GDK_OR:
-         xvalues.function = GXor;
-         break;
-       case GDK_EQUIV:
-         xvalues.function = GXequiv;
-         break;
-       case GDK_OR_REVERSE:
-         xvalues.function = GXorReverse;
-         break;
-       case GDK_COPY_INVERT:
-         xvalues.function = GXcopyInverted;
-         break;
-       case GDK_OR_INVERT:
-         xvalues.function = GXorInverted;
-         break;
-       case GDK_NAND:
-         xvalues.function = GXnand;
-         break;
-       case GDK_SET:
-         xvalues.function = GXset;
-         break;
-       }
-      xvalues_mask |= GCFunction;
-    }
-  if (values_mask & GDK_GC_FILL)
-    {
-      switch (values->fill)
-       {
-       case GDK_SOLID:
-         xvalues.fill_style = FillSolid;
-         break;
-       case GDK_TILED:
-         xvalues.fill_style = FillTiled;
-         break;
-       case GDK_STIPPLED:
-         xvalues.fill_style = FillStippled;
-         break;
-       case GDK_OPAQUE_STIPPLED:
-         xvalues.fill_style = FillOpaqueStippled;
-         break;
-       }
-      xvalues_mask |= GCFillStyle;
-    }
-  if (values_mask & GDK_GC_TILE)
-    {
-      xvalues.tile = GDK_DRAWABLE_XID (values->tile);
-      xvalues_mask |= GCTile;
-    }
-  if (values_mask & GDK_GC_STIPPLE)
-    {
-      xvalues.stipple = GDK_DRAWABLE_XID (values->stipple);
-      xvalues_mask |= GCStipple;
-    }
-  if (values_mask & GDK_GC_CLIP_MASK)
-    {
-      xvalues.clip_mask = GDK_DRAWABLE_XID (values->clip_mask);
-      xvalues_mask |= GCClipMask;
-    }
-  if (values_mask & GDK_GC_SUBWINDOW)
-    {
-      xvalues.subwindow_mode = values->subwindow_mode;
-      xvalues_mask |= GCSubwindowMode;
-    }
-  if (values_mask & GDK_GC_TS_X_ORIGIN)
-    {
-      xvalues.ts_x_origin = values->ts_x_origin;
-      xvalues_mask |= GCTileStipXOrigin;
-    }
-  if (values_mask & GDK_GC_TS_Y_ORIGIN)
-    {
-      xvalues.ts_y_origin = values->ts_y_origin;
-      xvalues_mask |= GCTileStipYOrigin;
-    }
-  if (values_mask & GDK_GC_CLIP_X_ORIGIN)
-    {
-      xvalues.clip_x_origin = values->clip_x_origin;
-      xvalues_mask |= GCClipXOrigin;
-    }
-  if (values_mask & GDK_GC_CLIP_Y_ORIGIN)
-    {
-      xvalues.clip_y_origin = values->clip_y_origin;
-      xvalues_mask |= GCClipYOrigin;
-    }
-  if (values_mask & GDK_GC_EXPOSURES)
-    xvalues.graphics_exposures = values->graphics_exposures;
-  else
-    xvalues.graphics_exposures = False;
-  xvalues_mask |= GCGraphicsExposures;
-
-  if (values_mask & GDK_GC_LINE_WIDTH)
-    {
-      xvalues.line_width = values->line_width;
-      xvalues_mask |= GCLineWidth;
-    }
-  if (values_mask & GDK_GC_LINE_STYLE)
-    {
-      switch (values->line_style)
-       {
-       case GDK_LINE_SOLID:
-         xvalues.line_style = LineSolid;
-         break;
-       case GDK_LINE_ON_OFF_DASH:
-         xvalues.line_style = LineOnOffDash;
-         break;
-       case GDK_LINE_DOUBLE_DASH:
-         xvalues.line_style = LineDoubleDash;
-         break;
-       }
-      xvalues_mask |= GCLineStyle;
-    }
-  if (values_mask & GDK_GC_CAP_STYLE)
-    {
-      switch (values->cap_style)
-       {
-       case GDK_CAP_NOT_LAST:
-         xvalues.cap_style = CapNotLast;
-         break;
-       case GDK_CAP_BUTT:
-         xvalues.cap_style = CapButt;
-         break;
-       case GDK_CAP_ROUND:
-         xvalues.cap_style = CapRound;
-         break;
-       case GDK_CAP_PROJECTING:
-         xvalues.cap_style = CapProjecting;
-         break;
-       }
-      xvalues_mask |= GCCapStyle;
-    }
-  if (values_mask & GDK_GC_JOIN_STYLE)
-    {
-      switch (values->join_style)
-       {
-       case GDK_JOIN_MITER:
-         xvalues.join_style = JoinMiter;
-         break;
-       case GDK_JOIN_ROUND:
-         xvalues.join_style = JoinRound;
-         break;
-       case GDK_JOIN_BEVEL:
-         xvalues.join_style = JoinBevel;
-         break;
-       }
-      xvalues_mask |= GCJoinStyle;
-    }
-
-  private->xgc = XCreateGC (private->xdisplay, xwindow, xvalues_mask, &xvalues);
-
-  return gc;
+  return gdk_gc_new_with_values (drawable, NULL, 0);
 }
 
-void
-gdk_gc_destroy (GdkGC *gc)
+GdkGC*
+gdk_gc_new_with_values (GdkDrawable    *drawable,
+                       GdkGCValues     *values,
+                       GdkGCValuesMask  values_mask)
 {
-  gdk_gc_unref (gc);
+  g_return_val_if_fail (drawable != NULL, NULL);
+
+  if (GDK_DRAWABLE_DESTROYED (drawable))
+    return NULL;
+
+  return ((GdkDrawablePrivate *)drawable)->klass->create_gc (drawable,
+                                                            values,
+                                                            values_mask);
 }
 
 GdkGC *
@@ -287,332 +88,118 @@ gdk_gc_unref (GdkGC *gc)
   g_return_if_fail (gc != NULL);
   g_return_if_fail (private->ref_count > 0);
   
-  if (private->ref_count > 1)
-    private->ref_count -= 1;
-  else
-    {
-      XFreeGC (private->xdisplay, private->xgc);
-      memset (gc, 0, sizeof (GdkGCPrivate));
-      g_free (gc);
-    }
+  private->ref_count--;
+
+  if (private->ref_count == 0)
+    private->klass->destroy (gc);
 }
 
 void
 gdk_gc_get_values (GdkGC       *gc,
                   GdkGCValues *values)
 {
-  GdkGCPrivate *private;
-  XGCValues xvalues;
+  g_return_if_fail (gc != NULL);
+  g_return_if_fail (values != NULL);
 
+  ((GdkGCPrivate *)gc)->klass->get_values (gc, values);
+}
+
+void
+gdk_gc_set_values (GdkGC           *gc,
+                  GdkGCValues     *values,
+                  GdkGCValuesMask  values_mask)
+{
   g_return_if_fail (gc != NULL);
   g_return_if_fail (values != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  if (XGetGCValues (private->xdisplay, private->xgc,
-                   GCForeground | GCBackground | GCFont |
-                   GCFunction | GCTile | GCStipple | /* GCClipMask | */
-                   GCSubwindowMode | GCGraphicsExposures |
-                   GCTileStipXOrigin | GCTileStipYOrigin |
-                   GCClipXOrigin | GCClipYOrigin |
-                   GCLineWidth | GCLineStyle | GCCapStyle |
-                   GCFillStyle | GCJoinStyle, &xvalues))
-    {
-      values->foreground.pixel = xvalues.foreground;
-      values->background.pixel = xvalues.background;
-      values->font = gdk_font_lookup (xvalues.font);
-
-      switch (xvalues.function)
-       {
-       case GXcopy:
-         values->function = GDK_COPY;
-         break;
-       case GXinvert:
-         values->function = GDK_INVERT;
-         break;
-       case GXxor:
-         values->function = GDK_XOR;
-         break;
-       case GXclear:
-         values->function = GDK_CLEAR;
-         break;
-       case GXand:
-         values->function = GDK_AND;
-         break;
-       case GXandReverse:
-         values->function = GDK_AND_REVERSE;
-         break;
-       case GXandInverted:
-         values->function = GDK_AND_INVERT;
-         break;
-       case GXnoop:
-         values->function = GDK_NOOP;
-         break;
-       case GXor:
-         values->function = GDK_OR;
-         break;
-       case GXequiv:
-         values->function = GDK_EQUIV;
-         break;
-       case GXorReverse:
-         values->function = GDK_OR_REVERSE;
-         break;
-       case GXcopyInverted:
-         values->function =GDK_COPY_INVERT;
-         break;
-       case GXorInverted:
-         values->function = GDK_OR_INVERT;
-         break;
-       case GXnand:
-         values->function = GDK_NAND;
-         break;
-       case GXset:
-         values->function = GDK_SET;
-         break;
-       }
-
-      switch (xvalues.fill_style)
-       {
-       case FillSolid:
-         values->fill = GDK_SOLID;
-         break;
-       case FillTiled:
-         values->fill = GDK_TILED;
-         break;
-       case FillStippled:
-         values->fill = GDK_STIPPLED;
-         break;
-       case FillOpaqueStippled:
-         values->fill = GDK_OPAQUE_STIPPLED;
-         break;
-       }
-
-      values->tile = gdk_pixmap_lookup (xvalues.tile);
-      values->stipple = gdk_pixmap_lookup (xvalues.stipple);
-      values->clip_mask = NULL;
-      values->subwindow_mode = xvalues.subwindow_mode;
-      values->ts_x_origin = xvalues.ts_x_origin;
-      values->ts_y_origin = xvalues.ts_y_origin;
-      values->clip_x_origin = xvalues.clip_x_origin;
-      values->clip_y_origin = xvalues.clip_y_origin;
-      values->graphics_exposures = xvalues.graphics_exposures;
-      values->line_width = xvalues.line_width;
-
-      switch (xvalues.line_style)
-       {
-       case LineSolid:
-         values->line_style = GDK_LINE_SOLID;
-         break;
-       case LineOnOffDash:
-         values->line_style = GDK_LINE_ON_OFF_DASH;
-         break;
-       case LineDoubleDash:
-         values->line_style = GDK_LINE_DOUBLE_DASH;
-         break;
-       }
-
-      switch (xvalues.cap_style)
-       {
-       case CapNotLast:
-         values->cap_style = GDK_CAP_NOT_LAST;
-         break;
-       case CapButt:
-         values->cap_style = GDK_CAP_BUTT;
-         break;
-       case CapRound:
-         values->cap_style = GDK_CAP_ROUND;
-         break;
-       case CapProjecting:
-         values->cap_style = GDK_CAP_PROJECTING;
-         break;
-       }
-
-      switch (xvalues.join_style)
-       {
-       case JoinMiter:
-         values->join_style = GDK_JOIN_MITER;
-         break;
-       case JoinRound:
-         values->join_style = GDK_JOIN_ROUND;
-         break;
-       case JoinBevel:
-         values->join_style = GDK_JOIN_BEVEL;
-         break;
-       }
-    }
-  else
-    {
-      memset (values, 0, sizeof (GdkGCValues));
-    }
+  ((GdkGCPrivate *)gc)->klass->set_values (gc, values, values_mask);
 }
 
 void
 gdk_gc_set_foreground (GdkGC   *gc,
                       GdkColor *color)
 {
-  GdkGCPrivate *private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
   g_return_if_fail (color != NULL);
 
-  private = (GdkGCPrivate*) gc;
-  XSetForeground (private->xdisplay, private->xgc, color->pixel);
+  values.foreground = *color;
+  gdk_gc_set_values (gc, &values, GDK_GC_FOREGROUND);
 }
 
 void
 gdk_gc_set_background (GdkGC   *gc,
                       GdkColor *color)
 {
-  GdkGCPrivate *private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
   g_return_if_fail (color != NULL);
 
-  private = (GdkGCPrivate*) gc;
-  XSetBackground (private->xdisplay, private->xgc, color->pixel);
+  values.background = *color;
+  gdk_gc_set_values (gc, &values, GDK_GC_BACKGROUND);
 }
 
 void
 gdk_gc_set_font (GdkGC  *gc,
                 GdkFont *font)
 {
-  GdkGCPrivate *gc_private;
-  GdkFontPrivate *font_private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
   g_return_if_fail (font != NULL);
 
-  if (font->type == GDK_FONT_FONT)
-    {
-      gc_private = (GdkGCPrivate*) gc;
-      font_private = (GdkFontPrivate*) font;
-      
-      XSetFont (gc_private->xdisplay, gc_private->xgc,
-               ((XFontStruct *) font_private->xfont)->fid);
-    }
+  values.font = font;
+  gdk_gc_set_values (gc, &values, GDK_GC_FONT);
 }
 
 void
 gdk_gc_set_function (GdkGC      *gc,
                     GdkFunction  function)
 {
-  GdkGCPrivate *private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  switch (function)
-    {
-    case GDK_COPY:
-      XSetFunction (private->xdisplay, private->xgc, GXcopy);
-      break;
-    case GDK_INVERT:
-      XSetFunction (private->xdisplay, private->xgc, GXinvert);
-      break;
-    case GDK_XOR:
-      XSetFunction (private->xdisplay, private->xgc, GXxor);
-      break;
-    case GDK_CLEAR:
-      XSetFunction (private->xdisplay, private->xgc, GXclear);
-      break;
-    case GDK_AND:
-      XSetFunction (private->xdisplay, private->xgc, GXand);
-      break;
-    case GDK_AND_REVERSE:
-      XSetFunction (private->xdisplay, private->xgc, GXandReverse);
-      break;
-    case GDK_AND_INVERT:
-      XSetFunction (private->xdisplay, private->xgc, GXandInverted);
-      break;
-    case GDK_NOOP:
-      XSetFunction (private->xdisplay, private->xgc, GXnoop);
-      break;
-    case GDK_OR:
-      XSetFunction (private->xdisplay, private->xgc, GXor);
-      break;
-    case GDK_EQUIV:
-      XSetFunction (private->xdisplay, private->xgc, GXequiv);
-      break;
-    case GDK_OR_REVERSE:
-      XSetFunction (private->xdisplay, private->xgc, GXorReverse);
-      break;
-    case GDK_COPY_INVERT:
-      XSetFunction (private->xdisplay, private->xgc, GXcopyInverted);
-      break;
-    case GDK_OR_INVERT:
-      XSetFunction (private->xdisplay, private->xgc, GXorInverted);
-      break;
-    case GDK_NAND:
-      XSetFunction (private->xdisplay, private->xgc, GXnand);
-      break;
-    case GDK_SET:
-      XSetFunction (private->xdisplay, private->xgc, GXset);
-      break;
-    }
+  values.function = function;
+  gdk_gc_set_values (gc, &values, GDK_GC_FUNCTION);
 }
 
 void
 gdk_gc_set_fill (GdkGC  *gc,
                 GdkFill  fill)
 {
-  GdkGCPrivate *private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  switch (fill)
-    {
-    case GDK_SOLID:
-      XSetFillStyle (private->xdisplay, private->xgc, FillSolid);
-      break;
-    case GDK_TILED:
-      XSetFillStyle (private->xdisplay, private->xgc, FillTiled);
-      break;
-    case GDK_STIPPLED:
-      XSetFillStyle (private->xdisplay, private->xgc, FillStippled);
-      break;
-    case GDK_OPAQUE_STIPPLED:
-      XSetFillStyle (private->xdisplay, private->xgc, FillOpaqueStippled);
-      break;
-    }
+  values.fill = fill;
+  gdk_gc_set_values (gc, &values, GDK_GC_FILL);
 }
 
 void
 gdk_gc_set_tile (GdkGC    *gc,
                 GdkPixmap *tile)
 {
-  GdkGCPrivate *private;
-  Pixmap pixmap;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  pixmap = None;
-  if (tile)
-    pixmap = GDK_DRAWABLE_XID (tile);
-
-  XSetTile (private->xdisplay, private->xgc, pixmap);
+  values.tile = tile;
+  gdk_gc_set_values (gc, &values, GDK_GC_TILE);
 }
 
 void
 gdk_gc_set_stipple (GdkGC     *gc,
                    GdkPixmap *stipple)
 {
-  GdkGCPrivate *private;
-  Pixmap pixmap;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  pixmap = None;
-  if (stipple)
-    pixmap = GDK_DRAWABLE_XID (stipple);
-
-  XSetStipple (private->xdisplay, private->xgc, pixmap);
+  values.stipple = stipple;
+  gdk_gc_set_values (gc, &values, GDK_GC_STIPPLE);
 }
 
 void
@@ -620,13 +207,15 @@ gdk_gc_set_ts_origin (GdkGC *gc,
                      gint   x,
                      gint   y)
 {
-  GdkGCPrivate *private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  XSetTSOrigin (private->xdisplay, private->xgc, x, y);
+  values.ts_x_origin = x;
+  values.ts_x_origin = y;
+  
+  gdk_gc_set_values (gc, &values,
+                    GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN);
 }
 
 void
@@ -634,105 +223,52 @@ gdk_gc_set_clip_origin (GdkGC *gc,
                        gint   x,
                        gint   y)
 {
-  GdkGCPrivate *private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  XSetClipOrigin (private->xdisplay, private->xgc, x, y);
+  values.clip_x_origin = x;
+  values.clip_x_origin = y;
+  
+  gdk_gc_set_values (gc, &values,
+                    GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN);
 }
 
 void
 gdk_gc_set_clip_mask (GdkGC    *gc,
                      GdkBitmap *mask)
 {
-  GdkGCPrivate *private;
-  Pixmap xmask;
+  GdkGCValues values;
   
   g_return_if_fail (gc != NULL);
   
-  if (mask)
-    xmask = GDK_DRAWABLE_XID (mask);
-  else
-    xmask = None;
-  
-  private = (GdkGCPrivate*) gc;
-
-  XSetClipMask (private->xdisplay, private->xgc, xmask);
+  values.clip_mask = mask;
+  gdk_gc_set_values (gc, &values, GDK_GC_CLIP_MASK);
 }
 
 
-void
-gdk_gc_set_clip_rectangle (GdkGC       *gc,
-                          GdkRectangle *rectangle)
-{
-  GdkGCPrivate *private;
-  XRectangle xrectangle;
-   
-  g_return_if_fail (gc != NULL);
-
-  private = (GdkGCPrivate*) gc;
-
-  if (rectangle)
-    {
-      xrectangle.x = rectangle->x; 
-      xrectangle.y = rectangle->y;
-      xrectangle.width = rectangle->width;
-      xrectangle.height = rectangle->height;
-      
-      XSetClipRectangles (private->xdisplay, private->xgc, 0, 0,
-                         &xrectangle, 1, Unsorted);
-    }
-  else
-    XSetClipMask (private->xdisplay, private->xgc, None);
-} 
-
-void
-gdk_gc_set_clip_region (GdkGC           *gc,
-                       GdkRegion        *region)
-{
-  GdkGCPrivate *private;
-
-  g_return_if_fail (gc != NULL);
-
-  private = (GdkGCPrivate*) gc;
-
-  if (region)
-    {
-      GdkRegionPrivate *region_private;
-
-      region_private = (GdkRegionPrivate*) region;
-      XSetRegion (private->xdisplay, private->xgc, region_private->xregion);
-    }
-  else
-    XSetClipMask (private->xdisplay, private->xgc, None);
-}
-
 void
 gdk_gc_set_subwindow (GdkGC           *gc,
                      GdkSubwindowMode  mode)
 {
-  GdkGCPrivate *private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  XSetSubwindowMode (private->xdisplay, private->xgc, mode);
+  values.subwindow_mode = mode;
+  gdk_gc_set_values (gc, &values, GDK_GC_SUBWINDOW);
 }
 
 void
-gdk_gc_set_exposures (GdkGC *gc,
-                     gint   exposures)
+gdk_gc_set_exposures (GdkGC     *gc,
+                     gboolean   exposures)
 {
-  GdkGCPrivate *private;
+  GdkGCValues values;
 
   g_return_if_fail (gc != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  XSetGraphicsExposures (private->xdisplay, private->xgc, exposures);
+  values.graphics_exposures = exposures;
+  gdk_gc_set_values (gc, &values, GDK_GC_EXPOSURES);
 }
 
 void
@@ -742,65 +278,18 @@ gdk_gc_set_line_attributes (GdkGC *gc,
                            GdkCapStyle  cap_style,
                            GdkJoinStyle join_style)
 {
-  GdkGCPrivate *private;
-  int xline_style;
-  int xcap_style;
-  int xjoin_style;
-
-  g_return_if_fail (gc != NULL);
-
-  private = (GdkGCPrivate*) gc;
-
-  switch (line_style)
-    {
-    case GDK_LINE_SOLID:
-      xline_style = LineSolid;
-      break;
-    case GDK_LINE_ON_OFF_DASH:
-      xline_style = LineOnOffDash;
-      break;
-    case GDK_LINE_DOUBLE_DASH:
-      xline_style = LineDoubleDash;
-      break;
-    default:
-      xline_style = None;
-    }
-
-  switch (cap_style)
-    {
-    case GDK_CAP_NOT_LAST:
-      xcap_style = CapNotLast;
-      break;
-    case GDK_CAP_BUTT:
-      xcap_style = CapButt;
-      break;
-    case GDK_CAP_ROUND:
-      xcap_style = CapRound;
-      break;
-    case GDK_CAP_PROJECTING:
-      xcap_style = CapProjecting;
-      break;
-    default:
-      xcap_style = None;
-    }
-
-  switch (join_style)
-    {
-    case GDK_JOIN_MITER:
-      xjoin_style = JoinMiter;
-      break;
-    case GDK_JOIN_ROUND:
-      xjoin_style = JoinRound;
-      break;
-    case GDK_JOIN_BEVEL:
-      xjoin_style = JoinBevel;
-      break;
-    default:
-      xjoin_style = None;
-    }
-
-  XSetLineAttributes (private->xdisplay, private->xgc, line_width,
-                     xline_style, xcap_style, xjoin_style);
+  GdkGCValues values;
+
+  values.line_width = line_width;
+  values.line_style = line_style;
+  values.cap_style = cap_style;
+  values.join_style = join_style;
+
+  gdk_gc_set_values (gc, &values,
+                    GDK_GC_LINE_WIDTH |
+                    GDK_GC_LINE_STYLE |
+                    GDK_GC_CAP_STYLE |
+                    GDK_GC_JOIN_STYLE);
 }
 
 void
@@ -809,24 +298,8 @@ gdk_gc_set_dashes (GdkGC *gc,
                   gchar  dash_list[],
                   gint   n)
 {
-  GdkGCPrivate *private;
-
   g_return_if_fail (gc != NULL);
   g_return_if_fail (dash_list != NULL);
 
-  private = (GdkGCPrivate*) gc;
-
-  XSetDashes (private->xdisplay, private->xgc, dash_offset, dash_list, n);
-}
-
-void
-gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
-{
-  GdkGCPrivate *dst_private, *src_private;
-
-  src_private = (GdkGCPrivate *) src_gc;
-  dst_private = (GdkGCPrivate *) dst_gc;
-
-  XCopyGC (src_private->xdisplay, src_private->xgc, ~((~1) << GCLastBit),
-          dst_private->xgc);
+  ((GdkGCPrivate *)gc)->klass->set_dashes (gc, dash_offset, dash_list, n);
 }
index 907b7f674ff8713537a75bb6f783c730afd4faa0..0fe9deb2f36b8e772b2ba6614fc1287232c79c4b 100644 (file)
@@ -9,6 +9,7 @@ extern "C" {
 #endif /* __cplusplus */
 
 typedef struct _GdkGCValues          GdkGCValues;
+typedef struct _GdkGCClass           GdkGCClass;
 
 /* GC cap styles
  *  CapNotLast:
@@ -154,13 +155,31 @@ struct _GdkGC
   gint dummy_var;
 };
 
-GdkGC* gdk_gc_new                (GdkWindow        *window);
-GdkGC* gdk_gc_new_with_values    (GdkWindow        *window,
+struct _GdkGCClass 
+{
+  void (*destroy)        (GdkGC          *gc);
+  void (*get_values)     (GdkGC          *gc,
+                         GdkGCValues    *values);
+  void (*set_values)     (GdkGC          *gc,
+                         GdkGCValues    *values,
+                         GdkGCValuesMask mask);
+  void (*set_dashes)     (GdkGC          *gc,
+                         gint            dash_offset,
+                         gchar           dash_list[],
+                         gint            n);
+};
+
+
+GdkGC *gdk_gc_new                (GdkDrawable      *drawable);
+GdkGC *gdk_gc_alloc              (void);
+
+GdkGC *gdk_gc_new_with_values    (GdkDrawable      *drawable,
                                   GdkGCValues      *values,
                                   GdkGCValuesMask   values_mask);
-GdkGC* gdk_gc_ref                (GdkGC            *gc);
+void   gdk_gc_init                (GdkGC            *gc,
+                                  GdkGCClass       *klass);
+GdkGC *gdk_gc_ref                (GdkGC            *gc);
 void   gdk_gc_unref              (GdkGC            *gc);
-void   gdk_gc_destroy            (GdkGC            *gc);
 void   gdk_gc_get_values         (GdkGC            *gc,
                                   GdkGCValues      *values);
 void   gdk_gc_set_foreground     (GdkGC            *gc,
@@ -192,7 +211,7 @@ void   gdk_gc_set_clip_region         (GdkGC            *gc,
 void   gdk_gc_set_subwindow      (GdkGC            *gc,
                                   GdkSubwindowMode  mode);
 void   gdk_gc_set_exposures      (GdkGC            *gc,
-                                  gint              exposures);
+                                  gboolean          exposures);
 void   gdk_gc_set_line_attributes (GdkGC           *gc,
                                   gint              line_width,
                                   GdkLineStyle      line_style,
index ae6c066f963119e4845af9030d6d7d21dfbcda09..b925405f82bde16be00b714a0040beec59901ab6 100644 (file)
  */
 
 #include <stdio.h>
-#include <X11/Xlib.h>
 #include "gdktypes.h"
 #include "gdkprivate.h"
 #include "config.h"
 
 guint             gdk_debug_flags = 0;
-gint              gdk_use_xshm = TRUE;
-gchar            *gdk_display_name = NULL;
-Display          *gdk_display = NULL;
-gint              gdk_screen;
-Window            gdk_root_window;
-Window            gdk_leader_window;
-GdkWindowPrivate  gdk_root_parent = { { NULL, }, NULL, };
-Atom              gdk_wm_delete_window;
-Atom              gdk_wm_take_focus;
-Atom              gdk_wm_protocols;
-Atom              gdk_wm_window_protocols[2];
-Atom              gdk_selection_property;
-GdkDndCursorInfo  gdk_dnd_cursorinfo = {None, None, NULL, NULL,
-                                       {0,0}, {0,0}, NULL};
-GdkDndGlobals     gdk_dnd = {None,None,None,
-                            None,None,None,
-                            None,
-                            &gdk_dnd_cursorinfo,
-                            NULL,
-                            0,
-                            FALSE, FALSE, FALSE,
-                            None,
-                            {0,0},
-                            {0,0}, {0,0},
-                            {0,0,0,0}, NULL, None, 0};
-gchar            *gdk_progclass = NULL;
+GdkWindow        *gdk_parent_root = NULL;
 gint              gdk_error_code = 0;
 gint              gdk_error_warnings = TRUE;
-gint              gdk_null_window_warnings = TRUE;
 GList            *gdk_default_filters = NULL;
+GMutex           *gdk_threads_mutex = NULL;          /* Global GDK lock */
+GList            *gdk_queued_events = NULL;
+GList            *gdk_queued_tail = NULL;
 
-gboolean      gdk_xim_using;           /* using XIM Protocol if TRUE */
-#ifdef USE_XIM
-GdkICPrivate *gdk_xim_ic;              /* currently using IC */
-#endif /* USE_XIM */
-GdkWindow    *gdk_xim_window;          /* currently using Widow */
-
-GdkWindowPrivate *gdk_xgrab_window = NULL;  /* Window that currently holds the
-                                            *  x pointer grab
-                                            */
-
-GMutex *gdk_threads_mutex = NULL;          /* Global GDK lock */
-
-#ifdef USE_XIM
-GdkICPrivate *gdk_xim_ic;              /* currently using IC */
-GdkWindow *gdk_xim_window;             /* currently using Window */
-#endif
 
diff --git a/gdk/gdkim.c b/gdk/gdkim.c
deleted file mode 100644 (file)
index a13d1a6..0000000
+++ /dev/null
@@ -1,1598 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <X11/Xlocale.h>
-
-#include "gdk.h"               /* For gdk_flush() */
-#include "gdkim.h"
-#include "gdkpixmap.h"
-#include "gdkprivate.h"
-#include "gdki18n.h"
-#include "gdkx.h"
-
-#if HAVE_CONFIG_H
-#  include <config.h>
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#endif
-
-
-/* If this variable is FALSE, it indicates that we should
- * avoid trying to use multibyte conversion functions and
- * assume everything is 1-byte per character
- */
-static gboolean gdk_use_mb;
-
-#ifdef USE_XIM
-
-#include <stdarg.h>
-#include <X11/Xresource.h>
-
-/* The following routines duplicate functionality in Xlib to
- * translate from varargs to X's internal opaque XVaNestedList.
- * 
- * If all vendors have stuck close to the reference implementation,
- * then we should hopefully be OK. 
- */
-
-typedef struct {
-  gchar          *name;
-  gpointer value;
-} GdkImArg;
-
-#ifdef USE_X11R6_XIM
-static void   gdk_im_instantiate_cb      (Display *display,
-                                         XPointer client_data,
-                                         XPointer call_data);
-#endif
-static void   gdk_im_destroy_cb          (XIM im,
-                                         XPointer client_data,
-                                         XPointer call_data);
-static gint   gdk_im_real_open           (void);
-static void   gdk_ic_real_new            (GdkIC *ic);
-
-static GdkICAttributesType gdk_ic_real_set_attr (GdkIC *ic,
-                                                GdkICAttr           *attr,
-                                                GdkICAttributesType  mask);
-
-static XIM        xim_im;                      /* global IM */
-static XIMStyles* xim_styles;                  /* im supports these styles */
-static XIMStyle xim_best_allowed_style;
-static GList* xim_ic_list;
-
-#endif /* USE_XIM */
-
-/*
- *--------------------------------------------------------------
- * gdk_set_locale
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-gchar*
-gdk_set_locale (void)
-{
-  wchar_t result;
-  gchar *current_locale;
-
-  gdk_use_mb = FALSE;
-
-  if (!setlocale (LC_ALL,""))
-    g_warning ("locale not supported by C library");
-  
-  if (!XSupportsLocale ())
-    {
-      g_warning ("locale not supported by Xlib, locale set to C");
-      setlocale (LC_ALL, "C");
-    }
-  
-  if (!XSetLocaleModifiers (""))
-    g_warning ("can not set locale modifiers");
-
-  current_locale = setlocale (LC_ALL, NULL);
-
-  if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
-    {
-      gdk_use_mb = TRUE;
-
-#ifndef X_LOCALE
-      /* Detect GNU libc, where mb == UTF8. Not useful unless it's
-       * really a UTF8 locale. The below still probably will
-       * screw up on Greek, Cyrillic, etc, encoded as UTF8.
-       */
-      
-      if ((MB_CUR_MAX == 2) &&
-         (mbstowcs (&result, "\xdd\xa5", 1) > 0) &&
-         result == 0x765)
-       {
-         if ((strlen (current_locale) < 4) ||
-             g_strcasecmp (current_locale + strlen(current_locale) - 4, "utf8"))
-           gdk_use_mb = FALSE;
-       }
-#endif /* X_LOCALE */
-    }
-
-  GDK_NOTE (XIM,
-           g_message ("%s multi-byte string functions.", 
-                      gdk_use_mb ? "Using" : "Not using"));
-  
-  return current_locale;
-}
-
-#ifdef USE_XIM
-
-/*
- *--------------------------------------------------------------
- * gdk_im_begin
- *
- *   Begin using input method with XIM Protocol(X11R6 standard)
- *
- * Arguments:
- *   "ic" is the "Input Context" which is created by gtk_ic_new.
- *   The input area is specified with "window".
- *
- * Results:
- *   The gdk's event handling routine is switched to XIM based routine.
- *   XIM based routine uses XFilterEvent to get rid of events used by IM,
- *   and uses XmbLookupString instead of XLookupString.
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-void 
-gdk_im_begin (GdkIC *ic, GdkWindow* window)
-{
-  GdkICPrivate *private;
-  GdkICAttr attr;
-  
-  g_return_if_fail (ic != NULL);
-  
-  private = (GdkICPrivate *) ic;
-  
-  attr.focus_window = window;
-  gdk_ic_set_attr (ic, &attr, GDK_IC_FOCUS_WINDOW);
-
-  if (private != gdk_xim_ic)
-    {
-      gdk_im_end();
-      if (private->xic)
-       {
-         XSetICFocus (private->xic);
-         GDK_NOTE (XIM, g_message ("im_begin icfocus : %p(%ld)\n",
-                                   private->xic,
-                                   GDK_WINDOW_XWINDOW(private->attr->focus_window)));
-       }
-    }
-  gdk_xim_ic = private;
-  gdk_xim_window = window;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_im_end
- *
- *   End using input method with XIM Protocol(X11R6 standard)
- *
- * Arguments:
- *
- * Results:
- *   The gdk's event handling routine is switched to normal routine.
- *   User should call this function before ic and window will be destroyed.
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-void 
-gdk_im_end (void)
-{
-  if (gdk_xim_ic && gdk_xim_ic->xic)
-    {
-      XUnsetICFocus (gdk_xim_ic->xic);
-      GDK_NOTE (XIM, g_message ("im_end unfocus : %p\n", gdk_xim_ic->xic));
-    }
-  gdk_xim_ic = NULL;
-  gdk_xim_window = NULL;
-}
-
-static GdkIMStyle 
-gdk_im_choose_better_style (GdkIMStyle style1, GdkIMStyle style2) 
-{
-  GdkIMStyle s1, s2, u;
-  
-  if (style1 == 0) return style2;
-  if (style2 == 0) return style1;
-  if ((style1 & (GDK_IM_PREEDIT_MASK | GDK_IM_STATUS_MASK))
-       == (style2 & (GDK_IM_PREEDIT_MASK | GDK_IM_STATUS_MASK)))
-    return style1;
-
-  s1 = style1 & GDK_IM_PREEDIT_MASK;
-  s2 = style2 & GDK_IM_PREEDIT_MASK;
-  u = s1 | s2;
-  if (s1 != s2) {
-    if (u & GDK_IM_PREEDIT_CALLBACKS)
-      return (s1 == GDK_IM_PREEDIT_CALLBACKS)? style1:style2;
-    else if (u & GDK_IM_PREEDIT_POSITION)
-      return (s1 == GDK_IM_PREEDIT_POSITION)? style1:style2;
-    else if (u & GDK_IM_PREEDIT_AREA)
-      return (s1 == GDK_IM_PREEDIT_AREA)? style1:style2;
-    else if (u & GDK_IM_PREEDIT_NOTHING)
-      return (s1 == GDK_IM_PREEDIT_NOTHING)? style1:style2;
-  } else {
-    s1 = style1 & GDK_IM_STATUS_MASK;
-    s2 = style2 & GDK_IM_STATUS_MASK;
-    u = s1 | s2;
-    if ( u & GDK_IM_STATUS_CALLBACKS)
-      return (s1 == GDK_IM_STATUS_CALLBACKS)? style1:style2;
-    else if ( u & GDK_IM_STATUS_AREA)
-      return (s1 == GDK_IM_STATUS_AREA)? style1:style2;
-    else if ( u & GDK_IM_STATUS_NOTHING)
-      return (s1 == GDK_IM_STATUS_NOTHING)? style1:style2;
-    else if ( u & GDK_IM_STATUS_NONE)
-      return (s1 == GDK_IM_STATUS_NONE)? style1:style2;
-  }
-  return 0; /* Get rid of stupid warning */
-}
-
-GdkIMStyle
-gdk_im_decide_style (GdkIMStyle supported_style)
-{
-  gint i;
-  GdkIMStyle style, tmp;
-  
-  g_return_val_if_fail (xim_styles != NULL, 0);
-  
-  style = 0;
-  for (i=0; i<xim_styles->count_styles; i++)
-    {
-      tmp = xim_styles->supported_styles[i];
-      if (tmp == (tmp & supported_style & xim_best_allowed_style))
-       style = gdk_im_choose_better_style (style, tmp);
-    }
-  return style;
-}
-
-GdkIMStyle
-gdk_im_set_best_style (GdkIMStyle style)
-{
-  if (style & GDK_IM_PREEDIT_MASK)
-    {
-      xim_best_allowed_style &= ~GDK_IM_PREEDIT_MASK;
-
-      xim_best_allowed_style |= GDK_IM_PREEDIT_NONE;
-      if (!(style & GDK_IM_PREEDIT_NONE))
-       {
-         xim_best_allowed_style |= GDK_IM_PREEDIT_NOTHING;
-         if (!(style & GDK_IM_PREEDIT_NOTHING))
-           {
-             xim_best_allowed_style |= GDK_IM_PREEDIT_AREA;
-             if (!(style & GDK_IM_PREEDIT_AREA))
-               {
-                 xim_best_allowed_style |= GDK_IM_PREEDIT_POSITION;
-                 if (!(style & GDK_IM_PREEDIT_POSITION))
-                   xim_best_allowed_style |= GDK_IM_PREEDIT_CALLBACKS;
-               }
-           }
-       }
-    }
-  if (style & GDK_IM_STATUS_MASK)
-    {
-      xim_best_allowed_style &= ~GDK_IM_STATUS_MASK;
-
-      xim_best_allowed_style |= GDK_IM_STATUS_NONE;
-      if (!(style & GDK_IM_STATUS_NONE))
-       {
-         xim_best_allowed_style |= GDK_IM_STATUS_NOTHING;
-         if (!(style & GDK_IM_STATUS_NOTHING))
-           {
-             xim_best_allowed_style |= GDK_IM_STATUS_AREA;
-             if (!(style & GDK_IM_STATUS_AREA))
-               xim_best_allowed_style |= GDK_IM_STATUS_CALLBACKS;
-           }
-       }
-    }
-  
-  return xim_best_allowed_style;
-}
-
-#ifdef USE_X11R6_XIM
-static void
-gdk_im_destroy_cb (XIM im, XPointer client_data, XPointer call_data)
-{
-  GList *node;
-  GdkICPrivate *private;
-
-  GDK_NOTE (XIM, g_message ("Ouch, Input Method is destroyed!!\n"));
-
-  xim_im = NULL;
-
-  if (xim_styles)
-    {
-      XFree (xim_styles);
-      xim_styles = NULL;
-    }
-
-  for (node = xim_ic_list; node != NULL; node = g_list_next(node))
-    {
-      private = (GdkICPrivate *) (node->data);
-      private->xic = NULL;
-    }
-
-  XRegisterIMInstantiateCallback (gdk_display, NULL, NULL, NULL,
-                                 gdk_im_instantiate_cb, NULL);
-}
-
-static void
-gdk_im_instantiate_cb (Display *display,
-                      XPointer client_data, XPointer call_data)
-{
-  GDK_NOTE (XIM, g_message ("New IM is instantiated."));
-  if (display != gdk_display)
-    return;
-
-  gdk_im_real_open ();
-
-  if (xim_im != NULL)
-    XUnregisterIMInstantiateCallback (gdk_display, NULL, NULL, NULL,
-                                     gdk_im_instantiate_cb, NULL);
-}
-#endif
-
-static gint
-gdk_im_real_open (void)
-{
-  GList *node;
-
-  xim_im = XOpenIM (GDK_DISPLAY(), NULL, NULL, NULL);
-  if (xim_im == NULL)
-    {
-      GDK_NOTE (XIM, g_warning ("Unable to open IM."));
-      return FALSE;
-    }
-  else
-    {
-#ifdef USE_X11R6_XIM
-      XIMCallback destroy_cb;
-
-      destroy_cb.callback = gdk_im_destroy_cb;
-      destroy_cb.client_data = NULL;
-      if (NULL != (void *) XSetIMValues (xim_im, XNDestroyCallback, &destroy_cb, NULL))
-       GDK_NOTE (XIM, g_warning ("Could not set destroy callback to IM. Be careful to not destroy your input method."));
-#endif
-
-      XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
-
-      for (node = xim_ic_list; node != NULL; node = g_list_next(node))
-       {
-         GdkICPrivate *private = (GdkICPrivate *) (node->data);
-         if (private->xic == NULL)
-           gdk_ic_real_new ((GdkIC *)private);
-       }
-      return TRUE;
-    }
-}
-
-gint 
-gdk_im_open (void)
-{
-  gdk_xim_ic = NULL;
-  gdk_xim_window = (GdkWindow*)NULL;
-  xim_im = NULL;
-  xim_styles = NULL;
-
-  /* initialize XIM Protocol variables */
-  if (!(xim_best_allowed_style & GDK_IM_PREEDIT_MASK))
-    gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
-  if (!(xim_best_allowed_style & GDK_IM_STATUS_MASK))
-    gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
-
-  if (gdk_im_real_open ())
-    return TRUE;
-
-#ifdef USE_X11R6_XIM
-  XRegisterIMInstantiateCallback (gdk_display, NULL, NULL, NULL,
-                                 gdk_im_instantiate_cb, NULL);
-#endif
-
-  return FALSE;
-}
-
-void 
-gdk_im_close (void)
-{
-  if (xim_im)
-    {
-      XCloseIM (xim_im);
-      xim_im = NULL;
-    }
-  if (xim_styles)
-    {
-      XFree (xim_styles);
-      xim_styles = NULL;
-    }
-}
-
-gint 
-gdk_im_ready (void)
-{
-  return (xim_im != NULL);
-}
-
-static void
-gdk_ic_real_new (GdkIC *ic)
-{
-  XPoint spot_location;
-  XRectangle preedit_area;
-  XRectangle status_area;
-  XVaNestedList *preedit_attr = NULL;
-  XVaNestedList *status_attr = NULL;
-  GdkICAttr *attr;
-  GdkICPrivate *private;
-  GdkICAttributesType mask = GDK_IC_ALL_REQ;
-
-  private = (GdkICPrivate *) ic;
-  attr = private->attr;
-
-  switch (attr->style & GDK_IM_PREEDIT_MASK)
-    {
-    case GDK_IM_PREEDIT_AREA:
-      mask |= GDK_IC_PREEDIT_AREA_REQ;
-
-      preedit_area.x = attr->preedit_area.x;
-      preedit_area.y = attr->preedit_area.y;
-      preedit_area.width = attr->preedit_area.width;
-      preedit_area.height = attr->preedit_area.height;
-
-      preedit_attr = XVaCreateNestedList (0,
-                                         XNArea, &preedit_area,
-                                         XNFontSet,
-                                         GDK_FONT_XFONT(attr->preedit_fontset),
-                                         NULL);
-      break;
-
-    case GDK_IM_PREEDIT_POSITION:
-      mask |= GDK_IC_PREEDIT_POSITION_REQ;
-
-      preedit_area.x = attr->preedit_area.x;
-      preedit_area.y = attr->preedit_area.y;
-      preedit_area.width = attr->preedit_area.width;
-      preedit_area.height = attr->preedit_area.height;
-
-      spot_location.x = attr->spot_location.x;
-      spot_location.y = attr->spot_location.y;
-
-      preedit_attr = XVaCreateNestedList (0,
-                                         XNArea, &preedit_area,
-                                         XNFontSet,
-                                         GDK_FONT_XFONT(attr->preedit_fontset),
-                                         XNSpotLocation, &spot_location,
-                                         NULL);
-      break;
-    }
-
-  switch (attr->style & GDK_IM_STATUS_MASK)
-    {
-    case GDK_IM_STATUS_AREA:
-      mask |= GDK_IC_STATUS_AREA_REQ;
-
-      status_area.x = attr->status_area.x;
-      status_area.y = attr->status_area.y;
-      status_area.width = attr->status_area.width;
-      status_area.height = attr->status_area.height;
-
-      status_attr = XVaCreateNestedList (0,
-                                        XNArea, &status_area,
-                                        XNFontSet,
-                                        GDK_FONT_XFONT(attr->status_fontset),
-                                        NULL);
-      break;
-    }
-
-  /* We have to ensure that the client window is actually created on
-   * the X server, or XCreateIC fails because the XIM server can't get
-   * information about the client window.
-   */
-  gdk_flush();
-  
-  if (preedit_attr != NULL && status_attr != NULL)
-    private->xic = XCreateIC (xim_im,
-                             XNInputStyle,
-                             attr->style,
-                             XNClientWindow,
-                             GDK_WINDOW_XWINDOW(attr->client_window),
-                             XNPreeditAttributes,
-                             preedit_attr,
-                             XNStatusAttributes,
-                             status_attr,
-                             NULL);
-  else if (preedit_attr != NULL)
-    private->xic = XCreateIC (xim_im,
-                             XNInputStyle,
-                             attr->style,
-                             XNClientWindow,
-                             GDK_WINDOW_XWINDOW(attr->client_window),
-                             XNPreeditAttributes,
-                             preedit_attr,
-                             NULL);
-  else if (status_attr != NULL)
-    private->xic = XCreateIC (xim_im,
-                             XNInputStyle,
-                             attr->style,
-                             XNClientWindow,
-                             GDK_WINDOW_XWINDOW(attr->client_window),
-                             XNStatusAttributes,
-                             status_attr,
-                             NULL);
-  else
-    private->xic = XCreateIC (xim_im,
-                             XNInputStyle,
-                             attr->style,
-                             XNClientWindow,
-                             GDK_WINDOW_XWINDOW(attr->client_window),
-                             NULL);
-
-  if (preedit_attr)
-    XFree (preedit_attr);
-  if (status_attr)
-    XFree (status_attr);
-
-  if (private->xic == NULL)
-    g_warning ("can not create input context with specified input style.");
-  else
-    gdk_ic_real_set_attr (ic, private->attr, private->mask & ~mask);
-}
-
-GdkIC *
-gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
-{
-  GdkICPrivate *private;
-  gboolean error = 0;
-  GdkICAttributesType invalid_mask;
-  GdkICAttr *pattr;
-
-  g_return_val_if_fail (attr != NULL, NULL);
-  g_return_val_if_fail ((mask & GDK_IC_ALL_REQ) == GDK_IC_ALL_REQ, NULL);
-
-  switch (attr->style & GDK_IM_PREEDIT_MASK)
-    {
-    case 0:
-      g_warning ("preedit style is not specified.\n");
-      error = 1;
-      break;
-
-    case GDK_IM_PREEDIT_AREA:
-      if ((mask & GDK_IC_PREEDIT_AREA_REQ) != GDK_IC_PREEDIT_AREA_REQ)
-       error = 4;
-      break;
-
-    case GDK_IM_PREEDIT_POSITION:
-      if ((mask & GDK_IC_PREEDIT_POSITION_REQ) != GDK_IC_PREEDIT_POSITION_REQ)
-       error = 4;
-      break;
-    }
-
-  switch (attr->style & GDK_IM_STATUS_MASK)
-    {
-    case 0:
-      g_warning ("status style is not specified.\n");
-      error = 2;
-      break;
-
-    case GDK_IM_STATUS_AREA:
-      if ((mask & GDK_IC_STATUS_AREA_REQ) != GDK_IC_STATUS_AREA_REQ)
-       error = 8;
-      break;
-    }
-
-  if (error)
-    {
-      if (error & 12)
-       g_warning ("IC attribute is not enough to required input style.\n");
-      return NULL;
-    }
-
-  if (attr->client_window == NULL ||
-      GDK_DRAWABLE_DESTROYED (attr->client_window))
-    {
-      g_warning ("Client_window is null or already destroyed.\n");
-      return NULL;
-    }
-
-  private = g_new0 (GdkICPrivate, 1);
-  private->attr = pattr = gdk_ic_attr_new ();
-
-  gdk_window_ref (attr->client_window);
-  pattr->client_window = attr->client_window;
-  pattr->style = attr->style;
-  private->mask = GDK_IC_STYLE | GDK_IC_CLIENT_WINDOW;
-  
-  /* XIC is still not created, so following call only copies attributes */
-  invalid_mask = gdk_ic_set_attr ((GdkIC *)private, attr, mask & ~GDK_IC_ALL_REQ);
-
-  switch (attr->style & GDK_IM_PREEDIT_MASK)
-    {
-    case GDK_IM_PREEDIT_AREA:
-      if (invalid_mask & GDK_IC_PREEDIT_AREA_REQ)
-       error = TRUE;
-      break;
-
-    case GDK_IM_PREEDIT_POSITION:
-      if (invalid_mask & GDK_IC_PREEDIT_POSITION_REQ)
-       error = TRUE;
-      break;
-    }
-
-  switch (attr->style & GDK_IM_STATUS_MASK)
-    {
-    case GDK_IM_STATUS_AREA:
-      if (invalid_mask & GDK_IC_STATUS_AREA_REQ)
-       error = TRUE;
-      break;
-    }
-
-  if (error == TRUE)
-    {
-      g_warning ("Essential attributes for required style are invalid.\n");
-      gdk_ic_destroy ((GdkIC *)private);
-      return NULL;
-    }
-
-  if (gdk_im_ready ())
-    gdk_ic_real_new ((GdkIC *)private);
-
-  xim_ic_list = g_list_append (xim_ic_list, private);
-  
-  return (GdkIC *)private;
-}
-
-void 
-gdk_ic_destroy (GdkIC *ic)
-{
-  GdkICPrivate *private;
-  
-  g_return_if_fail (ic != NULL);
-  
-  private = (GdkICPrivate *) ic;
-  
-  if (gdk_xim_ic == private)
-    gdk_im_end ();
-  
-  GDK_NOTE (XIM, g_message ("ic_destroy %p\n", private->xic));
-  if (private->xic != NULL)
-    XDestroyIC (private->xic);
-
-  if (private->mask & GDK_IC_CLIENT_WINDOW)
-    gdk_window_unref (private->attr->client_window);
-  if (private->mask & GDK_IC_FOCUS_WINDOW)
-    gdk_window_unref (private->attr->focus_window);
-
-  if (private->mask & GDK_IC_PREEDIT_FONTSET)
-    gdk_font_unref (private->attr->preedit_fontset);
-  if (private->mask & GDK_IC_PREEDIT_PIXMAP)
-    gdk_pixmap_unref (private->attr->preedit_pixmap);
-  if (private->mask & GDK_IC_PREEDIT_COLORMAP)
-    gdk_colormap_unref (private->attr->preedit_colormap);
-
-  if (private->mask & GDK_IC_STATUS_FONTSET)
-    gdk_font_unref (private->attr->status_fontset);
-  if (private->mask & GDK_IC_STATUS_PIXMAP)
-    gdk_pixmap_unref (private->attr->status_pixmap);
-  if (private->mask & GDK_IC_STATUS_COLORMAP)
-    gdk_colormap_unref (private->attr->status_colormap);
-
-  xim_ic_list = g_list_remove (xim_ic_list, private);
-  gdk_ic_attr_destroy (private->attr);
-  g_free (private);
-}
-
-GdkIMStyle
-gdk_ic_get_style (GdkIC *ic)
-{
-  GdkICPrivate *private;
-  
-  g_return_val_if_fail (ic != NULL, 0);
-  
-  private = (GdkICPrivate *) ic;
-  
-  return private->attr->style;
-}
-
-/*
- * for keeping binary compatibility if member of ic attributes is added.
- */
-GdkICAttr *
-gdk_ic_attr_new (void)
-{
-  return g_new0 (GdkICAttr, 1);
-}
-
-void
-gdk_ic_attr_destroy (GdkICAttr *attr)
-{
-  g_return_if_fail (attr != NULL);
-
-  g_free (attr);
-}
-
-static GdkICAttributesType
-gdk_ic_real_set_attr (GdkIC *ic,
-                     GdkICAttr *attr,
-                     GdkICAttributesType mask)
-{
-  GdkICPrivate *private = (GdkICPrivate *)ic;
-  XIC xic = private->xic;
-  GdkICAttributesType error = 0;
-  GdkImArg arg[2] = {{NULL, NULL}, {NULL, NULL}};
-
-  if (mask & GDK_IC_FOCUS_WINDOW)
-    {
-      if (XSetICValues (xic, XNFocusWindow,
-                       GDK_WINDOW_XWINDOW(attr->focus_window), NULL) != NULL)
-       error |= GDK_IC_FOCUS_WINDOW;
-    }
-
-  if (mask & GDK_IC_SPOT_LOCATION)
-    {
-      XPoint point;
-
-      point.x = attr->spot_location.x;
-      point.y = attr->spot_location.y;
-
-      arg->name = XNSpotLocation;
-      arg->value = (gpointer) &point;
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_SPOT_LOCATION;
-    }
-
-  if (mask & GDK_IC_LINE_SPACING)
-    {
-      arg->name = XNLineSpace;
-      arg->value = GINT_TO_POINTER( attr->line_spacing );
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_LINE_SPACING;
-    }
-
-  if (mask & GDK_IC_CURSOR)
-    {
-      GdkCursorPrivate *cursor = (GdkCursorPrivate *) attr->cursor;
-
-      if (XSetICValues (xic, XNCursor, cursor->xcursor, NULL))
-       error |= GDK_IC_CURSOR;
-    }
-
-  if (mask & GDK_IC_PREEDIT_FONTSET)
-    {
-      arg->name = XNFontSet;
-      arg->value = (gpointer) GDK_FONT_XFONT(attr->preedit_fontset);
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_PREEDIT_FONTSET;
-    }
-
-  if (mask & GDK_IC_PREEDIT_AREA)
-    {
-      XRectangle rect;
-
-      rect.x = attr->preedit_area.x;
-      rect.y = attr->preedit_area.y;
-      rect.width = attr->preedit_area.width;
-      rect.height = attr->preedit_area.height;
-
-      arg->name = XNArea;
-      arg->value = (gpointer) &rect;
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_PREEDIT_AREA;
-    }
-
-  if (mask & GDK_IC_PREEDIT_AREA_NEEDED)
-    {
-      XRectangle rect;
-
-      rect.x = attr->preedit_area_needed.x;
-      rect.y = attr->preedit_area_needed.y;
-      rect.width = attr->preedit_area_needed.width;
-      rect.height = attr->preedit_area_needed.height;
-
-      arg->name = XNArea;
-      arg->value = (gpointer) &rect;
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_PREEDIT_AREA_NEEDED;
-      else
-       private->mask &= ~GDK_IC_PREEDIT_AREA_NEEDED;
-    }
-
-  if (mask & GDK_IC_PREEDIT_FOREGROUND)
-    {
-      arg->name = XNForeground;
-      arg->value = (gpointer) attr->preedit_foreground.pixel;
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_PREEDIT_FOREGROUND;
-    }
-
-  if (mask & GDK_IC_PREEDIT_BACKGROUND)
-    {
-      arg->name = XNBackground;
-      arg->value = (gpointer) attr->preedit_background.pixel;
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_PREEDIT_BACKGROUND;
-    }
-
-  if (mask & GDK_IC_PREEDIT_PIXMAP)
-    {
-      arg->name = XNBackgroundPixmap;
-      arg->value = (gpointer) GDK_WINDOW_XWINDOW(attr->preedit_pixmap);
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_PREEDIT_PIXMAP;
-    }
-
-  if (mask & GDK_IC_PREEDIT_COLORMAP)
-    {
-      arg->name = XNColormap;
-      arg->value = (gpointer) GDK_COLORMAP_XCOLORMAP(attr->preedit_colormap);
-
-      if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
-       error |= GDK_IC_PREEDIT_COLORMAP;
-    }
-
-
-  if (mask & GDK_IC_STATUS_FONTSET)
-    {
-      arg->name = XNFontSet;
-      arg->value = (gpointer) GDK_FONT_XFONT(attr->status_fontset);
-
-      if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
-       error |= GDK_IC_STATUS_FONTSET;
-    }
-
-  if (mask & GDK_IC_STATUS_AREA)
-    {
-      XRectangle rect;
-
-      rect.x = attr->status_area.x;
-      rect.y = attr->status_area.y;
-      rect.width = attr->status_area.width;
-      rect.height = attr->status_area.height;
-
-      arg->name = XNArea;
-      arg->value = (gpointer) &rect;
-
-      if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
-       error |= GDK_IC_STATUS_AREA;
-    }
-
-  if (mask & GDK_IC_STATUS_AREA_NEEDED)
-    {
-      XRectangle rect;
-
-      rect.x = attr->status_area_needed.x;
-      rect.y = attr->status_area_needed.y;
-      rect.width = attr->status_area_needed.width;
-      rect.height = attr->status_area_needed.height;
-
-      arg->name = XNArea;
-      arg->value = (gpointer) &rect;
-
-      if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
-       error |= GDK_IC_STATUS_AREA_NEEDED;
-      else
-       private->mask &= ~GDK_IC_STATUS_AREA_NEEDED;
-    }
-
-  if (mask & GDK_IC_STATUS_FOREGROUND)
-    {
-      arg->name = XNForeground;
-      arg->value = (gpointer) attr->status_foreground.pixel;
-
-      if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
-       error |= GDK_IC_STATUS_FOREGROUND;
-    }
-
-  if (mask & GDK_IC_STATUS_BACKGROUND)
-    {
-      arg->name = XNBackground;
-      arg->value = (gpointer) attr->status_background.pixel;
-
-      if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
-       error |= GDK_IC_STATUS_BACKGROUND;
-    }
-
-  if (mask & GDK_IC_STATUS_PIXMAP)
-    {
-      arg->name = XNBackgroundPixmap;
-      arg->value = (gpointer) GDK_WINDOW_XWINDOW(attr->status_pixmap);
-
-      if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
-       error |= GDK_IC_STATUS_PIXMAP;
-    }
-
-  if (mask & GDK_IC_STATUS_COLORMAP)
-    {
-      arg->name = XNColormap;
-      arg->value = (gpointer) GDK_COLORMAP_XCOLORMAP(attr->status_colormap);
-
-      if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
-       error |= GDK_IC_STATUS_COLORMAP;
-    }
-
-  return error;
-}
-
-GdkICAttributesType
-gdk_ic_set_attr (GdkIC *ic,
-                GdkICAttr *attr,
-                GdkICAttributesType mask)
-{
-  GdkICPrivate *private;
-  GdkICAttr *pattr;
-  GdkICAttributesType error = 0;
-  GdkICAttributesType newattr = 0;
-
-  g_return_val_if_fail (ic != NULL, 0);
-  g_return_val_if_fail (attr != NULL, 0);
-
-  private = (GdkICPrivate *) ic;
-  pattr = private->attr;
-
-  /* Check and copy new attributes */
-
-  if (mask & GDK_IC_STYLE)
-    {
-      g_warning ("input style can be specified only when creating new ic.\n");
-      error |= GDK_IC_STYLE;
-    }
-
-  if (mask & GDK_IC_FILTER_EVENTS)
-    {
-      g_warning ("filter events is read only attributes.\n");
-      error |= GDK_IC_FILTER_EVENTS;
-    }
-
-  if (mask & GDK_IC_CLIENT_WINDOW)
-    {
-      g_warning ("client window can be specified only when creating new ic.\n");
-      error |= GDK_IC_CLIENT_WINDOW;
-    }
-
-  if (mask & GDK_IC_FOCUS_WINDOW)
-    {
-      if (attr->focus_window == NULL)
-       {
-         g_warning ("specified focus_window is invalid.\n");
-         error |= GDK_IC_FOCUS_WINDOW;
-       }
-      else if (pattr->focus_window != attr->focus_window)
-       {
-         if (pattr->focus_window != NULL)
-           gdk_window_unref (pattr->focus_window);
-         if (attr->focus_window != NULL)
-           gdk_window_ref (attr->focus_window);
-         pattr->focus_window = attr->focus_window;
-         newattr |= GDK_IC_FOCUS_WINDOW;
-       }
-    }
-
-  if (mask & GDK_IC_SPOT_LOCATION)
-    {
-      pattr->spot_location = attr->spot_location;
-      newattr |= GDK_IC_SPOT_LOCATION;
-    }
-
-  if (mask & GDK_IC_LINE_SPACING)
-    {
-      pattr->line_spacing = attr->line_spacing;
-      newattr |= GDK_IC_LINE_SPACING;
-    }
-
-  if (mask & GDK_IC_CURSOR)
-    {
-      pattr->cursor = attr->cursor;
-      newattr |= GDK_IC_CURSOR;
-    }
-
-  if (mask & GDK_IC_PREEDIT_FONTSET)
-    {
-      if (attr->preedit_fontset == NULL ||
-         attr->preedit_fontset->type != GDK_FONT_FONTSET)
-       {
-         g_warning ("gdk_font is NULL or not a fontset.\n");
-         error |= GDK_IC_PREEDIT_FONTSET;
-       }
-      else if (pattr->preedit_fontset != attr->preedit_fontset)
-       {
-         if (pattr->preedit_fontset != NULL)
-           gdk_font_unref (pattr->preedit_fontset);
-         if (attr->preedit_fontset != NULL)
-           gdk_font_ref (attr->preedit_fontset);
-         pattr->preedit_fontset = attr->preedit_fontset;
-         newattr |= GDK_IC_PREEDIT_FONTSET;
-       }
-    }
-
-  if (mask & GDK_IC_PREEDIT_AREA)
-    {
-      pattr->preedit_area = attr->preedit_area;
-      newattr |= GDK_IC_PREEDIT_AREA;
-    }
-
-  if (mask & GDK_IC_PREEDIT_AREA_NEEDED)
-    {
-      if (attr->preedit_area_needed.width == 0 ||
-         attr->preedit_area_needed.height == 0)
-       {
-         g_warning ("width and height of preedit_area_needed must be non 0.\n");
-         error |= GDK_IC_PREEDIT_AREA_NEEDED;
-       }
-      else
-       {
-         pattr->preedit_area_needed = attr->preedit_area_needed;
-         newattr |= GDK_IC_PREEDIT_AREA_NEEDED;
-       }
-    }
-
-  if (mask & GDK_IC_PREEDIT_FOREGROUND)
-    {
-      pattr->preedit_foreground = attr->preedit_foreground;
-      newattr |= GDK_IC_PREEDIT_FOREGROUND;
-    }
-
-  if (mask & GDK_IC_PREEDIT_BACKGROUND)
-    {
-      pattr->preedit_background = attr->preedit_background;
-      newattr |= GDK_IC_PREEDIT_BACKGROUND;
-    }
-
-  if (mask & GDK_IC_PREEDIT_PIXMAP)
-    {
-      if (attr->preedit_pixmap != NULL &&
-         GDK_DRAWABLE_DESTROYED (attr->preedit_pixmap))
-       {
-         g_warning ("Preedit pixmap is already destroyed.\n");
-         error |= GDK_IC_PREEDIT_PIXMAP;
-       }
-      else
-       {
-         if (pattr->preedit_pixmap != attr->preedit_pixmap)
-           {
-             if (pattr->preedit_pixmap != NULL)
-               gdk_pixmap_unref (pattr->preedit_pixmap);
-             if (attr->preedit_pixmap)
-               gdk_pixmap_ref (attr->preedit_pixmap);
-             pattr->preedit_pixmap = attr->preedit_pixmap;
-             newattr |= GDK_IC_PREEDIT_PIXMAP;
-           }
-       }
-    }
-
-  if (mask & GDK_IC_PREEDIT_COLORMAP)
-    {
-      if (pattr->preedit_colormap != attr->preedit_colormap)
-       {
-         if (pattr->preedit_colormap != NULL)
-           gdk_colormap_unref (pattr->preedit_colormap);
-         if (attr->preedit_colormap != NULL)
-           gdk_colormap_ref (attr->preedit_colormap);
-         pattr->preedit_colormap = attr->preedit_colormap;
-         newattr |= GDK_IC_PREEDIT_COLORMAP;
-       }
-    }
-
-  if (mask & GDK_IC_STATUS_FONTSET)
-    {
-      if (attr->status_fontset == NULL ||
-         attr->status_fontset->type != GDK_FONT_FONTSET)
-       {
-         g_warning ("gdk_font is NULL or not a fontset.\n");
-         error |= GDK_IC_STATUS_FONTSET;
-       }
-      else if (pattr->status_fontset != attr->status_fontset)
-       {
-         if (pattr->status_fontset != NULL)
-           gdk_font_unref (pattr->status_fontset);
-         if (attr->status_fontset != NULL)
-           gdk_font_ref (attr->status_fontset);
-         pattr->status_fontset = attr->status_fontset;
-         newattr |= GDK_IC_STATUS_FONTSET;
-       }
-    }
-
-  if (mask & GDK_IC_STATUS_AREA)
-    {
-      pattr->status_area = attr->status_area;
-      newattr |= GDK_IC_STATUS_AREA;
-    }
-
-  if (mask & GDK_IC_STATUS_AREA_NEEDED)
-    {
-      if (attr->status_area_needed.width == 0 ||
-         attr->status_area_needed.height == 0)
-       {
-         g_warning ("width and height of status_area_needed must be non 0.\n");
-         error |= GDK_IC_STATUS_AREA_NEEDED;
-       }
-      else
-       {
-         pattr->status_area_needed = attr->status_area_needed;
-         newattr |= GDK_IC_STATUS_AREA_NEEDED;
-       }
-    }
-
-  if (mask & GDK_IC_STATUS_FOREGROUND)
-    {
-      pattr->status_foreground = attr->status_foreground;
-      newattr |= GDK_IC_STATUS_FOREGROUND;
-    }
-
-  if (mask & GDK_IC_STATUS_BACKGROUND)
-    {
-      pattr->status_background = attr->status_background;
-      newattr |= GDK_IC_STATUS_BACKGROUND;
-    }
-
-  if (mask & GDK_IC_STATUS_PIXMAP)
-    {
-      if (attr->status_pixmap != NULL &&
-         GDK_DRAWABLE_DESTROYED (attr->status_pixmap))
-       {
-         g_warning ("Preedit pixmap is already destroyed.\n");
-         error |= GDK_IC_STATUS_PIXMAP;
-       }
-      else
-       {
-         if (pattr->status_pixmap != attr->status_pixmap)
-           {
-             if (pattr->status_pixmap != NULL)
-               gdk_pixmap_unref (pattr->status_pixmap);
-             if (attr->status_pixmap)
-               gdk_pixmap_ref (attr->status_pixmap);
-             pattr->status_pixmap = attr->status_pixmap;
-             newattr |= GDK_IC_STATUS_PIXMAP;
-           }
-       }
-    }
-
-  if (mask & GDK_IC_STATUS_COLORMAP)
-    {
-      if (pattr->status_colormap != attr->status_colormap)
-       {
-         if (pattr->status_colormap != NULL)
-           gdk_colormap_unref (pattr->status_colormap);
-         if (attr->status_colormap != NULL)
-           gdk_colormap_ref (attr->status_colormap);
-         pattr->status_colormap = attr->status_colormap;
-         newattr |= GDK_IC_STATUS_COLORMAP;
-       }
-    }
-
-  if (private->xic == NULL)
-    return error;
-
-  error |= gdk_ic_real_set_attr (ic, pattr, newattr);
-
-  return error;
-}
-
-GdkICAttributesType
-gdk_ic_get_attr (GdkIC *ic,
-                GdkICAttr *attr,
-                GdkICAttributesType mask)
-{
-  GdkICPrivate *private;
-  GdkICAttr *pattr;
-  GdkICAttributesType known, unknown = 0;
-
-  g_return_val_if_fail (ic != NULL, -1);
-  g_return_val_if_fail (attr != NULL, -1);
-
-  private = (GdkICPrivate *) ic;
-  pattr = private->attr;
-
-  known = mask & private->mask;
-
-  if (known & GDK_IC_STYLE)
-    attr->style = pattr->style;
-  if (known & GDK_IC_CLIENT_WINDOW)
-    attr->client_window = pattr->client_window;
-  if (known & GDK_IC_FOCUS_WINDOW)
-    attr->focus_window = pattr->focus_window;
-  if (known & GDK_IC_FILTER_EVENTS)
-    attr->filter_events = pattr->filter_events;
-  if (known & GDK_IC_LINE_SPACING)
-    attr->line_spacing = pattr->line_spacing;
-  if (known & GDK_IC_CURSOR)
-    attr->cursor = pattr->cursor;
-
-  if (known & GDK_IC_PREEDIT_FONTSET)
-    attr->preedit_fontset = pattr->preedit_fontset;
-  if (known & GDK_IC_PREEDIT_AREA)
-    attr->preedit_area = pattr->preedit_area;
-  if (known & GDK_IC_PREEDIT_AREA_NEEDED)
-    attr->preedit_area_needed = pattr->preedit_area_needed;
-  if (known & GDK_IC_PREEDIT_FOREGROUND)
-    attr->preedit_foreground = pattr->preedit_foreground;
-  if (known & GDK_IC_PREEDIT_BACKGROUND)
-    attr->preedit_background = pattr->preedit_background;
-  if (known & GDK_IC_PREEDIT_PIXMAP)
-    attr->preedit_pixmap = pattr->preedit_pixmap;
-  if (known & GDK_IC_PREEDIT_COLORMAP)
-    attr->preedit_colormap = pattr->preedit_colormap;
-
-  if (known & GDK_IC_STATUS_FONTSET)
-    attr->status_fontset = pattr->status_fontset;
-  if (known & GDK_IC_STATUS_AREA)
-    attr->status_area = pattr->status_area;
-  if (known & GDK_IC_STATUS_AREA_NEEDED)
-    attr->status_area_needed = pattr->status_area_needed;
-  if (known & GDK_IC_STATUS_FOREGROUND)
-    attr->status_foreground = pattr->status_foreground;
-  if (known & GDK_IC_STATUS_BACKGROUND)
-    attr->status_background = pattr->status_background;
-  if (known & GDK_IC_STATUS_PIXMAP)
-    attr->status_pixmap = pattr->status_pixmap;
-  if (known & GDK_IC_STATUS_COLORMAP)
-    attr->status_colormap = pattr->status_colormap;
-
-  if (private->xic)
-    {
-      unknown = mask & ~(private->mask);
-
-      if (unknown & GDK_IC_FOCUS_WINDOW)
-       attr->focus_window = pattr->client_window;
-      if (unknown & GDK_IC_FILTER_EVENTS)
-       {
-         gdk_ic_get_events (ic);
-         attr->filter_events = pattr->filter_events;
-       }
-      if (mask & GDK_IC_SPOT_LOCATION)
-       {
-         XPoint point;
-         XVaNestedList *list;
-         
-         list = XVaCreateNestedList (0, XNSpotLocation, &point, NULL);
-         if (XGetICValues (private->xic, XNPreeditAttributes, list, NULL))
-           unknown &= ~GDK_IC_SPOT_LOCATION;
-         else
-           {
-             pattr->spot_location.x = point.x;
-             pattr->spot_location.y = point.y;
-             private->mask |= GDK_IC_SPOT_LOCATION;
-
-             attr->spot_location = pattr->spot_location;
-           }
-         XFree (list);
-       }
-      if (unknown & GDK_IC_PREEDIT_AREA_NEEDED)
-       {
-         XRectangle rect;
-         XVaNestedList *list;
-
-         list = XVaCreateNestedList (0, XNAreaNeeded, &rect, NULL);
-         if (XGetICValues (private->xic, XNPreeditAttributes, list, NULL))
-           unknown &= ~GDK_IC_PREEDIT_AREA_NEEDED;
-         else
-           {
-             pattr->preedit_area_needed.x = rect.x;
-             pattr->preedit_area_needed.y = rect.y;
-             pattr->preedit_area_needed.width = rect.width;
-             pattr->preedit_area_needed.height = rect.height;
-             private->mask |= GDK_IC_PREEDIT_AREA_NEEDED;
-
-             attr->preedit_area = pattr->preedit_area;
-           }
-         XFree (list);
-       }
-      if (unknown & GDK_IC_STATUS_AREA_NEEDED)
-       {
-         XRectangle rect;
-         XVaNestedList *list;
-
-         list = XVaCreateNestedList (0, XNAreaNeeded, &rect, NULL);
-         if (XGetICValues (private->xic, XNStatusAttributes, list, NULL))
-           unknown &= ~GDK_IC_STATUS_AREA_NEEDED;
-         else
-           {
-             pattr->status_area_needed.x = rect.x;
-             pattr->status_area_needed.y = rect.y;
-             pattr->status_area_needed.width = rect.width;
-             pattr->status_area_needed.height = rect.height;
-             private->mask |= GDK_IC_STATUS_AREA_NEEDED;
-
-             attr->status_area = pattr->status_area;
-           }
-         XFree (list);
-       }
-    }
-
-  return mask & ~known & ~unknown;
-}
-
-GdkEventMask 
-gdk_ic_get_events (GdkIC *ic)
-{
-  GdkEventMask mask;
-  glong xmask;
-  glong bit;
-  GdkICPrivate *private;
-  gint i;
-  
-  /*  From gdkwindow.c */
-  
-  g_return_val_if_fail (ic != NULL, 0);
-  
-  private = (GdkICPrivate *) ic;
-
-  if (private->mask & GDK_IC_FILTER_EVENTS)
-    return private->attr->filter_events;
-  
-  if (XGetICValues (private->xic, XNFilterEvents, &xmask, NULL) != NULL)
-    {
-      GDK_NOTE (XIM, g_warning ("Call to XGetICValues: %s failed", XNFilterEvents));
-      return 0;
-    }
-  
-  mask = 0;
-  for (i=0, bit=2; i < gdk_nevent_masks; i++, bit <<= 1)
-    if (xmask & gdk_event_mask_table [i])
-      {
-       mask |= bit;
-       xmask &= ~ gdk_event_mask_table [i];
-      }
-  
-  if (xmask)
-    g_warning ("ic requires events not supported by the application (%#04lx)", xmask);
-  
-  private->attr->filter_events = mask;
-  private->mask |= GDK_IC_FILTER_EVENTS;
-
-  return mask;
-}
-
-void 
-gdk_ic_cleanup (void)
-{
-  gint destroyed;
-  
-  destroyed = 0;
-  while (xim_ic_list != NULL)
-    {
-      gdk_ic_destroy ((GdkIC *) xim_ic_list->data);
-      destroyed ++;
-    }
-#ifdef G_ENABLE_DEBUG
-  if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0)
-    {
-      g_warning ("Cleaned up %i IC(s)\n", destroyed);
-    }
-#endif /* G_ENABLE_DEBUG */
-}
-
-#else /* !USE_XIM */
-
-void 
-gdk_im_begin (GdkIC *ic, GdkWindow* window)
-{
-}
-
-void 
-gdk_im_end (void)
-{
-}
-
-GdkIMStyle
-gdk_im_decide_style (GdkIMStyle supported_style)
-{
-  return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
-}
-
-GdkIMStyle
-gdk_im_set_best_style (GdkIMStyle style)
-{
-  return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
-}
-
-gint 
-gdk_im_ready (void)
-{
-  return FALSE;
-}
-
-GdkIC * 
-gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
-{
-  return NULL;
-}
-
-void 
-gdk_ic_destroy (GdkIC *ic)
-{
-}
-
-GdkIMStyle
-gdk_ic_get_style (GdkIC *ic)
-{
-  return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
-}
-
-void 
-gdk_ic_set_values (GdkIC *ic, ...)
-{
-}
-
-void 
-gdk_ic_get_values (GdkIC *ic, ...)
-{
-}
-
-GdkICAttributesType 
-gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
-{
-  return 0;
-}
-
-GdkICAttributesType 
-gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
-{
-  return 0;
-}
-
-GdkEventMask 
-gdk_ic_get_events (GdkIC *ic)
-{
-  return 0;
-}
-
-#endif /* USE_XIM */
-
-/*
- * gdk_wcstombs 
- *
- * Returns a multi-byte string converted from the specified array
- * of wide characters. The string is newly allocated. The array of
- * wide characters must be null-terminated. If the conversion is
- * failed, it returns NULL.
- */
-gchar *
-gdk_wcstombs (const GdkWChar *src)
-{
-  gchar *mbstr;
-
-  if (gdk_use_mb)
-    {
-      XTextProperty tpr;
-
-      if (sizeof(wchar_t) != sizeof(GdkWChar))
-       {
-         gint i;
-         wchar_t *src_alt;
-         for (i=0; src[i]; i++);
-         src_alt = g_new (wchar_t, i+1);
-         for (; i>=0; i--)
-           src_alt[i] = src[i];
-         if (XwcTextListToTextProperty (gdk_display, &src_alt, 1, XTextStyle, &tpr)
-             != Success)
-           {
-             g_free (src_alt);
-             return NULL;
-           }
-         g_free (src_alt);
-       }
-      else
-       {
-         if (XwcTextListToTextProperty (gdk_display, (wchar_t**)&src, 1,
-                                        XTextStyle, &tpr) != Success)
-           {
-             return NULL;
-           }
-       }
-      /*
-       * We must copy the string into an area allocated by glib, because
-       * the string 'tpr.value' must be freed by XFree().
-       */
-      mbstr = g_strdup(tpr.value);
-      XFree (tpr.value);
-    }
-  else
-    {
-      gint length = 0;
-      gint i;
-
-      while (src[length] != 0)
-       length++;
-      
-      mbstr = g_new (gchar, length + 1);
-
-      for (i=0; i<length+1; i++)
-       mbstr[i] = src[i];
-    }
-
-  return mbstr;
-}
-  
-/*
- * gdk_mbstowcs
- *
- * Converts the specified string into wide characters, and, returns the
- * number of wide characters written. The string 'src' must be
- * null-terminated. If the conversion is failed, it returns -1.
- */
-gint
-gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
-{
-  if (gdk_use_mb)
-    {
-      XTextProperty tpr;
-      wchar_t **wstrs, *wstr_src;
-      gint num_wstrs;
-      gint len_cpy;
-      if (XmbTextListToTextProperty (gdk_display, (char **)&src, 1, XTextStyle,
-                                    &tpr)
-         != Success)
-       {
-         /* NoMem or LocaleNotSupp */
-         return -1;
-       }
-      if (XwcTextPropertyToTextList (gdk_display, &tpr, &wstrs, &num_wstrs)
-         != Success)
-       {
-         /* InvalidChar */
-         XFree(tpr.value);
-         return -1;
-       }
-      XFree(tpr.value);
-      if (num_wstrs == 0)
-       return 0;
-      wstr_src = wstrs[0];
-      for (len_cpy=0; len_cpy<dest_max && wstr_src[len_cpy]; len_cpy++)
-       dest[len_cpy] = wstr_src[len_cpy];
-      XwcFreeStringList (wstrs);
-      return len_cpy;
-    }
-  else
-    {
-      gint i;
-
-      for (i=0; i<dest_max && src[i]; i++)
-       dest[i] = src[i];
-
-      return i;
-    }
-}
index 4facec7e75042273946b37f41bfb9fe97a5fd895..09ae112b6ddd0e0c2df169691316aeeef75c1bb5 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
-
-/* gcc -ansi -pedantic on GNU/Linux causes warnings and errors
- * unless this is defined:
- * warning: #warning "Files using this header must be compiled with _SVID_SOURCE or _XOPEN_SOURCE"
- */
-#ifndef _XOPEN_SOURCE
-#  define _XOPEN_SOURCE 1
-#endif
-
 #include <stdlib.h>
 #include <sys/types.h>
 
-#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
-#define USE_SHM
-#endif
-
-#ifdef USE_SHM
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#endif /* USE_SHM */
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#ifdef USE_SHM
-#include <X11/extensions/XShm.h>
-#endif /* USE_SHM */
-
-#include "gdk.h"               /* For gdk_error_trap_* / gdk_flush_* */
 #include "gdkimage.h"
 #include "gdkprivate.h"
-#include "gdkx.h"
-
-
-static void gdk_image_put_normal (GdkDrawable *drawable,
-                                 GdkGC       *gc,
-                                 GdkImage    *image,
-                                 gint         xsrc,
-                                 gint         ysrc,
-                                 gint         xdest,
-                                 gint         ydest,
-                                 gint         width,
-                                 gint         height);
-static void gdk_image_put_shared (GdkDrawable *drawable,
-                                 GdkGC       *gc,
-                                 GdkImage    *image,
-                                 gint         xsrc,
-                                 gint         ysrc,
-                                 gint         xdest,
-                                 gint         ydest,
-                                 gint         width,
-                                 gint         height);
-
-
-static GList *image_list = NULL;
-
-
-void
-gdk_image_exit (void)
-{
-  GdkImage *image;
-
-  while (image_list)
-    {
-      image = image_list->data;
-      gdk_image_destroy (image);
-    }
-}
 
 GdkImage *
-gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
-/*
- * Desc: create a new bitmap image
- */
+gdk_image_ref (GdkImage *image)
 {
-        Visual *xvisual;
-        GdkImage *image;
-        GdkImagePrivate *private;
-        private = g_new(GdkImagePrivate, 1);
-        image = (GdkImage *) private;
-        private->xdisplay = gdk_display;
-        private->image_put = gdk_image_put_normal;
-        image->type = GDK_IMAGE_NORMAL;
-        image->visual = visual;
-        image->width = w;
-        image->height = h;
-        image->depth = 1;
-        xvisual = ((GdkVisualPrivate*) visual)->xvisual;
-        private->ximage = XCreateImage(private->xdisplay, xvisual, 1, XYBitmap,
-                                      0, 0, w ,h, 8, 0);
-        private->ximage->data = data;
-        private->ximage->bitmap_bit_order = MSBFirst;
-        private->ximage->byte_order = MSBFirst;
-        image->byte_order = MSBFirst;
-        image->mem =  private->ximage->data;
-        image->bpl = private->ximage->bytes_per_line;
-        image->bpp = 1;
-       return(image);
-} /* gdk_image_new_bitmap() */
-
-static int
-gdk_image_check_xshm(Display *display)
-/* 
- * Desc: query the server for support for the MIT_SHM extension
- * Return:  0 = not available
- *          1 = shared XImage support available
- *          2 = shared Pixmap support available also
- */
-{
-#ifdef USE_SHM
-  int major, minor, ignore;
-  Bool pixmaps;
+  GdkImagePrivate *private = (GdkImagePrivate *)image;
   
-  if (XQueryExtension(display, "MIT-SHM", &ignore, &ignore, &ignore)) 
-    {
-      if (XShmQueryVersion(display, &major, &minor, &pixmaps )==True) 
-       {
-         return (pixmaps==True) ? 2 : 1;
-       }
-    }
-#endif /* USE_SHM */
-  return 0;
-}
+  g_return_val_if_fail (image != NULL, NULL);
 
-void
-gdk_image_init (void)
-{
-  if (gdk_use_xshm)
-    {
-      if (!gdk_image_check_xshm (gdk_display))
-       {
-         gdk_use_xshm = False;
-       }
-    }
-}
-
-GdkImage*
-gdk_image_new (GdkImageType  type,
-              GdkVisual    *visual,
-              gint          width,
-              gint          height)
-{
-  GdkImage *image;
-  GdkImagePrivate *private;
-#ifdef USE_SHM
-  XShmSegmentInfo *x_shm_info;
-#endif /* USE_SHM */
-  Visual *xvisual;
-
-  switch (type)
-    {
-    case GDK_IMAGE_FASTEST:
-      image = gdk_image_new (GDK_IMAGE_SHARED, visual, width, height);
-
-      if (!image)
-       image = gdk_image_new (GDK_IMAGE_NORMAL, visual, width, height);
-      break;
-
-    default:
-      private = g_new (GdkImagePrivate, 1);
-      image = (GdkImage*) private;
-
-      private->xdisplay = gdk_display;
-      private->image_put = NULL;
-
-      image->type = type;
-      image->visual = visual;
-      image->width = width;
-      image->height = height;
-      image->depth = visual->depth;
-
-      xvisual = ((GdkVisualPrivate*) visual)->xvisual;
-
-      switch (type)
-       {
-       case GDK_IMAGE_SHARED:
-#ifdef USE_SHM
-         if (gdk_use_xshm)
-           {
-             private->image_put = gdk_image_put_shared;
-
-             private->x_shm_info = g_new (XShmSegmentInfo, 1);
-             x_shm_info = private->x_shm_info;
-
-             private->ximage = XShmCreateImage (private->xdisplay, xvisual, visual->depth,
-                                                ZPixmap, NULL, x_shm_info, width, height);
-             if (private->ximage == NULL)
-               {
-                 g_warning ("XShmCreateImage failed");
-                 
-                 g_free (image);
-                 gdk_use_xshm = False;
-                 return NULL;
-               }
-
-             x_shm_info->shmid = shmget (IPC_PRIVATE,
-                                         private->ximage->bytes_per_line * private->ximage->height,
-                                         IPC_CREAT | 0777);
-
-             if (x_shm_info->shmid == -1)
-               {
-                 g_warning ("shmget failed!");
-
-                 XDestroyImage (private->ximage);
-                 g_free (private->x_shm_info);
-                 g_free (image);
-
-                 gdk_use_xshm = False;
-                 return NULL;
-               }
-
-             x_shm_info->readOnly = False;
-             x_shm_info->shmaddr = shmat (x_shm_info->shmid, 0, 0);
-             private->ximage->data = x_shm_info->shmaddr;
-
-             if (x_shm_info->shmaddr == (char*) -1)
-               {
-                 g_warning ("shmat failed!");
-
-                 XDestroyImage (private->ximage);
-                 shmctl (x_shm_info->shmid, IPC_RMID, 0);
-                 
-                 g_free (private->x_shm_info);
-                 g_free (image);
-
-                 return NULL;
-               }
-
-             gdk_error_trap_push ();
-
-             XShmAttach (private->xdisplay, x_shm_info);
-             XSync (private->xdisplay, False);
-
-             if (gdk_error_trap_pop ())
-               {
-                 /* this is the common failure case so omit warning */
-                 XDestroyImage (private->ximage);
-                 shmdt (x_shm_info->shmaddr);
-                 shmctl (x_shm_info->shmid, IPC_RMID, 0);
-                  
-                 g_free (private->x_shm_info);
-                 g_free (image);
-
-                 gdk_use_xshm = False;
-
-                 return NULL;
-               }
-             
-             /* We mark the segment as destroyed so that when
-              * the last process detaches, it will be deleted.
-              * There is a small possibility of leaking if
-              * we die in XShmAttach. In theory, a signal handler
-              * could be set up.
-              */
-             shmctl (x_shm_info->shmid, IPC_RMID, 0);                
-
-             if (image)
-               image_list = g_list_prepend (image_list, image);
-           }
-         else
-           {
-             g_free (image);
-             return NULL;
-           }
-         break;
-#else /* USE_SHM */
-         g_free (image);
-         return NULL;
-#endif /* USE_SHM */
-       case GDK_IMAGE_NORMAL:
-         private->image_put = gdk_image_put_normal;
-
-         private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth,
-                                         ZPixmap, 0, 0, width, height, 32, 0);
-
-         /* Use malloc, not g_malloc here, because X will call free()
-          * on this data
-          */
-         private->ximage->data = malloc (private->ximage->bytes_per_line *
-                                         private->ximage->height);
-         break;
-
-       case GDK_IMAGE_FASTEST:
-         g_assert_not_reached ();
-       }
-
-      if (image)
-       {
-         image->byte_order = private->ximage->byte_order;
-         image->mem = private->ximage->data;
-         image->bpl = private->ximage->bytes_per_line;
-         image->bpp = (private->ximage->bits_per_pixel + 7) / 8;
-       }
-    }
-
-  return image;
-}
-
-GdkImage*
-gdk_image_get (GdkWindow *window,
-              gint       x,
-              gint       y,
-              gint       width,
-              gint       height)
-{
-  GdkImage *image;
-  GdkImagePrivate *private;
-
-  g_return_val_if_fail (window != NULL, NULL);
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return NULL;
-
-  private = g_new (GdkImagePrivate, 1);
-  image = (GdkImage*) private;
-
-  private->xdisplay = gdk_display;
-  private->image_put = gdk_image_put_normal;
-  private->ximage = XGetImage (private->xdisplay,
-                              GDK_DRAWABLE_XID (window),
-                              x, y, width, height,
-                              AllPlanes, ZPixmap);
-
-  image->type = GDK_IMAGE_NORMAL;
-  image->visual = gdk_window_get_visual (window);
-  image->width = width;
-  image->height = height;
-  image->depth = private->ximage->depth;
-
-  image->mem = private->ximage->data;
-  image->bpl = private->ximage->bytes_per_line;
-  if (private->ximage->bits_per_pixel <= 8)
-    image->bpp = 1;
-  else if (private->ximage->bits_per_pixel <= 16)
-    image->bpp = 2;
-  else if (private->ximage->bits_per_pixel <= 24)
-    image->bpp = 3;
-  else
-    image->bpp = 4;
-  image->byte_order = private->ximage->byte_order;
-
-  return image;
-}
-
-guint32
-gdk_image_get_pixel (GdkImage *image,
-                    gint x,
-                    gint y)
-{
-  guint32 pixel;
-  GdkImagePrivate *private;
-
-  g_return_val_if_fail (image != NULL, 0);
-
-  private = (GdkImagePrivate *) image;
-
-  pixel = XGetPixel (private->ximage, x, y);
-
-  return pixel;
+  private->ref_count++;
 }
 
 void
-gdk_image_put_pixel (GdkImage *image,
-                    gint x,
-                    gint y,
-                    guint32 pixel)
+gdk_image_unref (GdkImage *image)
 {
-  GdkImagePrivate *private;
-
-  g_return_if_fail (image != NULL);
-
-  private = (GdkImagePrivate *) image;
-
-  pixel = XPutPixel (private->ximage, x, y, pixel);
-}
-
-void
-gdk_image_destroy (GdkImage *image)
-{
-  GdkImagePrivate *private;
-#ifdef USE_SHM
-  XShmSegmentInfo *x_shm_info;
-#endif /* USE_SHM */
-
-  g_return_if_fail (image != NULL);
-
-  private = (GdkImagePrivate*) image;
-  switch (image->type)
-    {
-    case GDK_IMAGE_NORMAL:
-      XDestroyImage (private->ximage);
-      break;
-
-    case GDK_IMAGE_SHARED:
-#ifdef USE_SHM
-      gdk_flush();
-
-      XShmDetach (private->xdisplay, private->x_shm_info);
-      XDestroyImage (private->ximage);
-
-      x_shm_info = private->x_shm_info;
-      shmdt (x_shm_info->shmaddr);
-      
-      g_free (private->x_shm_info);
-
-      image_list = g_list_remove (image_list, image);
-#else /* USE_SHM */
-      g_error ("trying to destroy shared memory image when gdk was compiled without shared memory support");
-#endif /* USE_SHM */
-      break;
-
-    case GDK_IMAGE_FASTEST:
-      g_assert_not_reached ();
-    }
-
-  g_free (image);
-}
-
-static void
-gdk_image_put_normal (GdkDrawable *drawable,
-                     GdkGC       *gc,
-                     GdkImage    *image,
-                     gint         xsrc,
-                     gint         ysrc,
-                     gint         xdest,
-                     gint         ydest,
-                     gint         width,
-                     gint         height)
-{
-  GdkImagePrivate *image_private;
-  GdkGCPrivate *gc_private;
-
-  g_return_if_fail (drawable != NULL);
+  GdkImagePrivate *private = (GdkImagePrivate *)image;
+  
   g_return_if_fail (image != NULL);
-  g_return_if_fail (gc != NULL);
-
-  if (GDK_DRAWABLE_DESTROYED (drawable))
-    return;
-  image_private = (GdkImagePrivate*) image;
-  gc_private = (GdkGCPrivate*) gc;
-
-  g_return_if_fail (image->type == GDK_IMAGE_NORMAL);
+  g_return_if_fail (private->ref_count > 0);
 
-  XPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), 
-            gc_private->xgc, image_private->ximage,
-            xsrc, ysrc, xdest, ydest, width, height);
+  private->ref_count--;
+  if (private->ref_count == 0)
+    private->klass->destroy (image);
 }
 
-static void
-gdk_image_put_shared (GdkDrawable *drawable,
-                     GdkGC       *gc,
-                     GdkImage    *image,
-                     gint         xsrc,
-                     gint         ysrc,
-                     gint         xdest,
-                     gint         ydest,
-                     gint         width,
-                     gint         height)
-{
-#ifdef USE_SHM
-  GdkImagePrivate *image_private;
-  GdkGCPrivate *gc_private;
-
-  g_return_if_fail (drawable != NULL);
-  g_return_if_fail (image != NULL);
-  g_return_if_fail (gc != NULL);
 
-  if (GDK_DRAWABLE_DESTROYED (drawable))
-    return;
-  image_private = (GdkImagePrivate*) image;
-  gc_private = (GdkGCPrivate*) gc;
-
-  g_return_if_fail (image->type == GDK_IMAGE_SHARED);
-
-  XShmPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), 
-               gc_private->xgc, image_private->ximage,
-               xsrc, ysrc, xdest, ydest, width, height, False);
-#else /* USE_SHM */
-  g_error ("trying to draw shared memory image when gdk was compiled without shared memory support");
-#endif /* USE_SHM */
-}
index 6077fd5b2caac04b287864352ea9550717cd0118..48cf507b5121c5ddb39c2a026179ad8d1f5fd27c 100644 (file)
@@ -42,7 +42,6 @@ struct _GdkImage
   gpointer     mem;
 };
 
-
 GdkImage* gdk_image_new_bitmap(GdkVisual     *visual,
                                gpointer      data,
                                gint          width,
@@ -56,12 +55,17 @@ GdkImage*  gdk_image_bitmap_new(GdkImageType  type,
                                GdkVisual    *visual,
                                gint          width,
                                gint          height);
+
 #endif
 GdkImage*  gdk_image_get       (GdkDrawable  *drawable,
                                gint          x,
                                gint          y,
                                gint          width,
                                gint          height);
+
+GdkImage * gdk_image_ref       (GdkImage     *image);
+void       gdk_image_unref     (GdkImage     *image);
+
 void      gdk_image_put_pixel (GdkImage     *image,
                                gint          x,
                                gint          y,
@@ -69,7 +73,6 @@ void     gdk_image_put_pixel (GdkImage     *image,
 guint32           gdk_image_get_pixel (GdkImage     *image,
                                gint          x,
                                gint          y);
-void      gdk_image_destroy   (GdkImage     *image);
 
 
 #ifdef __cplusplus
diff --git a/gdk/gdkinput.c b/gdk/gdkinput.c
deleted file mode 100644 (file)
index 334c3d4..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <stdlib.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include "config.h"
-
-#include "gdkx.h"
-#include "gdkinput.h"
-#include "gdkprivate.h"
-#include "gdkinputprivate.h"
-
-/* Forward declarations */
-
-static gint gdk_input_enable_window (GdkWindow *window,
-                                    GdkDevicePrivate *gdkdev);
-static gint gdk_input_disable_window (GdkWindow *window,
-                                     GdkDevicePrivate *gdkdev);
-static GdkInputWindow *gdk_input_window_find (GdkWindow *window);
-static GdkDevicePrivate *gdk_input_find_device (guint32 id);
-
-
-/* Incorporate the specific routines depending on compilation options */
-
-static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
-
-static const GdkDeviceInfo gdk_input_core_info =
-{
-  GDK_CORE_POINTER,
-  "Core Pointer",
-  GDK_SOURCE_MOUSE,
-  GDK_MODE_SCREEN,
-  TRUE,
-  2,
-  gdk_input_core_axes
-};
-
-/* Global variables  */
-
-GdkInputVTable    gdk_input_vtable;
-/* information about network port and host for gxid daemon */
-gchar            *gdk_input_gxid_host;
-gint              gdk_input_gxid_port;
-gint              gdk_input_ignore_core;
-
-/* Local variables */
-
-static GList            *gdk_input_devices;
-static GList            *gdk_input_windows;
-
-#include "gdkinputnone.h"
-#include "gdkinputcommon.h"
-#include "gdkinputxfree.h"
-#include "gdkinputgxi.h"
-
-GList *
-gdk_input_list_devices (void)
-{
-  return gdk_input_devices;
-}
-
-void
-gdk_input_set_source (guint32 deviceid, GdkInputSource source)
-{
-  GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
-  g_return_if_fail (gdkdev != NULL);
-
-  gdkdev->info.source = source;
-}
-
-gint
-gdk_input_set_mode (guint32 deviceid, GdkInputMode mode)
-{
-  if (deviceid == GDK_CORE_POINTER)
-    return FALSE;
-
-  if (gdk_input_vtable.set_mode)
-    return gdk_input_vtable.set_mode(deviceid,mode);
-  else
-    return FALSE;
-}
-
-void
-gdk_input_set_axes (guint32 deviceid, GdkAxisUse *axes)
-{
-  if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_axes)
-    gdk_input_vtable.set_axes (deviceid, axes);
-}
-
-void gdk_input_set_key (guint32 deviceid,
-                       guint   index,
-                       guint   keyval,
-                       GdkModifierType modifiers)
-{
-  if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_key)
-    gdk_input_vtable.set_key (deviceid, index, keyval, modifiers);
-}
-
-GdkTimeCoord *
-gdk_input_motion_events (GdkWindow *window,
-                        guint32 deviceid,
-                        guint32 start,
-                        guint32 stop,
-                        gint *nevents_return)
-{
-  XTimeCoord *xcoords;
-  GdkTimeCoord *coords;
-  int i;
-
-  g_return_val_if_fail (window != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-  
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return NULL;
-
-  if (deviceid == GDK_CORE_POINTER)
-    {
-      xcoords = XGetMotionEvents (GDK_DRAWABLE_XDISPLAY (window),
-                                 GDK_DRAWABLE_XID (window),
-                                 start, stop, nevents_return);
-      if (xcoords)
-       {
-         coords = g_new (GdkTimeCoord, *nevents_return);
-         for (i=0; i<*nevents_return; i++)
-           {
-             coords[i].time = xcoords[i].time;
-             coords[i].x = xcoords[i].x;
-             coords[i].y = xcoords[i].y;
-             coords[i].pressure = 0.5;
-             coords[i].xtilt = 0.0;
-             coords[i].ytilt = 0.0;
-           }
-
-         XFree (xcoords);
-
-         return coords;
-       }
-      else
-       return NULL;
-    }
-  else
-    {
-      if (gdk_input_vtable.motion_events)
-       {
-         return gdk_input_vtable.motion_events(window,
-                                               deviceid, start, stop,
-                                               nevents_return);
-       }
-      else
-       {
-         *nevents_return = 0;
-         return NULL;
-       }
-    }
-}
-
-static gint
-gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
-{
-  if (gdk_input_vtable.enable_window)
-    return gdk_input_vtable.enable_window (window, gdkdev);
-  else
-    return TRUE;
-}
-
-static gint
-gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
-{
-  if (gdk_input_vtable.disable_window)
-    return gdk_input_vtable.disable_window(window,gdkdev);
-  else
-    return TRUE;
-}
-
-
-static GdkInputWindow *
-gdk_input_window_find(GdkWindow *window)
-{
-  GList *tmp_list;
-
-  for (tmp_list=gdk_input_windows; tmp_list; tmp_list=tmp_list->next)
-    if (((GdkInputWindow *)(tmp_list->data))->window == window)
-      return (GdkInputWindow *)(tmp_list->data);
-
-  return NULL;      /* Not found */
-}
-
-/* FIXME: this routine currently needs to be called between creation
-   and the corresponding configure event (because it doesn't get the
-   root_relative_geometry).  This should work with
-   gtk_window_set_extension_events, but will likely fail in other
-   cases */
-
-void
-gdk_input_set_extension_events (GdkWindow *window, gint mask,
-                               GdkExtensionMode mode)
-{
-  GdkWindowPrivate *window_private;
-  GList *tmp_list;
-  GdkInputWindow *iw;
-
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-
-  window_private = (GdkWindowPrivate*) window;
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
-
-  if (mode == GDK_EXTENSION_EVENTS_NONE)
-    mask = 0;
-
-  if (mask != 0)
-    {
-      iw = g_new(GdkInputWindow,1);
-
-      iw->window = window;
-      iw->mode = mode;
-
-      iw->obscuring = NULL;
-      iw->num_obscuring = 0;
-      iw->grabbed = FALSE;
-
-      gdk_input_windows = g_list_append(gdk_input_windows,iw);
-      window_private->extension_events = mask;
-
-      /* Add enter window events to the event mask */
-      /* FIXME, this is not needed for XINPUT_NONE */
-      gdk_window_set_events (window,
-                            gdk_window_get_events (window) | 
-                            GDK_ENTER_NOTIFY_MASK);
-    }
-  else
-    {
-      iw = gdk_input_window_find (window);
-      if (iw)
-       {
-         gdk_input_windows = g_list_remove(gdk_input_windows,iw);
-         g_free(iw);
-       }
-
-      window_private->extension_events = 0;
-    }
-
-  for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
-    {
-      GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
-
-      if (gdkdev->info.deviceid != GDK_CORE_POINTER)
-       {
-         if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED
-             && (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL))
-           gdk_input_enable_window(window,gdkdev);
-         else
-           gdk_input_disable_window(window,gdkdev);
-       }
-    }
-}
-
-void
-gdk_input_window_destroy (GdkWindow *window)
-{
-  GdkInputWindow *input_window;
-
-  input_window = gdk_input_window_find (window);
-  g_return_if_fail (input_window != NULL);
-
-  gdk_input_windows = g_list_remove (gdk_input_windows,input_window);
-  g_free(input_window);
-}
-
-void
-gdk_input_exit (void)
-{
-  GList *tmp_list;
-  GdkDevicePrivate *gdkdev;
-
-  for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
-    {
-      gdkdev = (GdkDevicePrivate *)(tmp_list->data);
-      if (gdkdev->info.deviceid != GDK_CORE_POINTER)
-       {
-         gdk_input_set_mode(gdkdev->info.deviceid,GDK_MODE_DISABLED);
-
-         g_free(gdkdev->info.name);
-#ifndef XINPUT_NONE      
-         g_free(gdkdev->axes);
-#endif   
-         g_free(gdkdev->info.axes);
-         g_free(gdkdev->info.keys);
-         g_free(gdkdev);
-       }
-    }
-
-  g_list_free(gdk_input_devices);
-
-  for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
-    {
-      g_free(tmp_list->data);
-    }
-  g_list_free(gdk_input_windows);
-}
-
-static GdkDevicePrivate *
-gdk_input_find_device(guint32 id)
-{
-  GList *tmp_list = gdk_input_devices;
-  GdkDevicePrivate *gdkdev;
-  while (tmp_list)
-    {
-      gdkdev = (GdkDevicePrivate *)(tmp_list->data);
-      if (gdkdev->info.deviceid == id)
-       return gdkdev;
-      tmp_list = tmp_list->next;
-    }
-  return NULL;
-}
-
-void
-gdk_input_window_get_pointer (GdkWindow       *window,
-                             guint32     deviceid,
-                             gdouble         *x,
-                             gdouble         *y,
-                             gdouble         *pressure,
-                             gdouble         *xtilt,
-                             gdouble         *ytilt,
-                             GdkModifierType *mask)
-{
-  if (gdk_input_vtable.get_pointer)
-    gdk_input_vtable.get_pointer (window, deviceid, x, y, pressure,
-                                 xtilt, ytilt, mask);
-}
diff --git a/gdk/gdkinputcommon.h b/gdk/gdkinputcommon.h
deleted file mode 100644 (file)
index d9bb835..0000000
+++ /dev/null
@@ -1,892 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
-
-/* Forward declarations */
-static void gdk_input_get_root_relative_geometry (Display *dpy, Window w, 
-                                                 int *x_ret, int *y_ret,
-                                                 int *width_ret, 
-                                                 int *height_ret);
-static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device, 
-                                             gint include_core);
-static void gdk_input_common_find_events(GdkWindow *window,
-                                        GdkDevicePrivate *gdkdev,
-                                        gint mask,
-                                        XEventClass *classes,
-                                        int *num_classes);
-static void gdk_input_common_select_events(GdkWindow *window,
-                                          GdkDevicePrivate *gdkdev);
-static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
-                                           GdkInputWindow *input_window,
-                                           gint *axis_data,
-                                           gdouble *x, gdouble *y,
-                                           gdouble *pressure,
-                                           gdouble *xtilt, gdouble *ytilt);
-static guint gdk_input_translate_state(guint state, guint device_state);
-static gint gdk_input_common_init(gint include_core);
-static gint  gdk_input_common_other_event (GdkEvent *event, 
-                                          XEvent *xevent, 
-                                          GdkInputWindow *input_window,
-                                          GdkDevicePrivate *gdkdev);
-static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
-static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
-                                                     guint32 deviceid,
-                                                     guint32 start,
-                                                     guint32 stop,
-                                                     gint *nevents_return);
-static void  gdk_input_common_get_pointer     (GdkWindow       *window,
-                                              guint32     deviceid,
-                                              gdouble         *x,
-                                              gdouble         *y,
-                                              gdouble         *pressure,
-                                              gdouble         *xtilt,
-                                              gdouble         *ytilt,
-                                              GdkModifierType *mask);
-
-#define GDK_MAX_DEVICE_CLASSES 13
-
-/* Global variables */
-
-static gint gdk_input_root_width;
-static gint gdk_input_root_height;
-
-static void
-gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
-                              int *width_ret, int *height_ret)
-{
-  Window root,parent;
-  Window *children;
-  guint nchildren;
-  gint x,y;
-  guint width, height;
-  gint xc,yc;
-  guint widthc,heightc,border_widthc,depthc;
-  
-  XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
-  if (children) XFree(children);
-  XGetGeometry(dpy,w,&root,&x,&y,&width,&height,&border_widthc,
-              &depthc);
-  x += border_widthc;
-  y += border_widthc;
-
-  while (root != parent)
-    {
-      w = parent;
-      XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
-      if (children) XFree(children);
-      XGetGeometry(dpy,w,&root,&xc,&yc,&widthc,&heightc,
-                  &border_widthc,&depthc);
-      x += xc + border_widthc;
-      y += yc + border_widthc;
-    }
-
-  if (x_ret)
-    *x_ret = x;
-  if (y_ret)
-    *y_ret = y;
-  if (width_ret)
-    *width_ret = width;
-  if (height_ret)
-    *height_ret = height;
-}
-
-static GdkDevicePrivate *
-gdk_input_device_new(XDeviceInfo *device, gint include_core)
-{
-  GdkDevicePrivate *gdkdev;
-  gchar *tmp_name, *p;
-  XAnyClassPtr class;
-  gint i,j;
-
-  gdkdev = g_new(GdkDevicePrivate,1);
-
-  gdkdev->info.deviceid = device->id;
-  if (device->name[0]) {
-    gdkdev->info.name = g_new(char, strlen(device->name)+1);
-    strcpy(gdkdev->info.name,device->name);
-  } else {
-    /* XFree86 3.2 gives an empty name to the default core devices,
-       (fixed in 3.2A) */
-    gdkdev->info.name = g_strdup("pointer");
-    strcpy(gdkdev->info.name,"pointer");
-    gdkdev->info.source = GDK_SOURCE_MOUSE;
-  }
-
-  gdkdev->info.mode = GDK_MODE_DISABLED;
-
-  /* Try to figure out what kind of device this is by its name -
-     could invite a very, very, long list... Lowercase name
-     for comparison purposes */
-
-  tmp_name = g_strdup(gdkdev->info.name);
-  for (p = tmp_name; *p; p++)
-    {
-      if (*p >= 'A' && *p <= 'Z')
-       *p += 'a' - 'A';
-    }
-  
-  if (!strcmp (tmp_name, "pointer"))
-    gdkdev->info.source = GDK_SOURCE_MOUSE;
-  else if (!strcmp (tmp_name, "wacom") ||
-          !strcmp (tmp_name, "pen"))
-    gdkdev->info.source = GDK_SOURCE_PEN;
-  else if (!strcmp (tmp_name, "eraser"))
-    gdkdev->info.source = GDK_SOURCE_ERASER;
-  else if (!strcmp (tmp_name, "cursor"))
-    gdkdev->info.source = GDK_SOURCE_CURSOR;
-  else
-    gdkdev->info.source = GDK_SOURCE_PEN;
-
-  g_free(tmp_name);
-
-  gdkdev->xdevice = NULL;
-
-  /* step through the classes */
-
-  gdkdev->info.num_axes = 0;
-  gdkdev->info.num_keys = 0;
-  gdkdev->info.keys = NULL;
-  gdkdev->axes = 0;
-  gdkdev->info.has_cursor = 0;
-  gdkdev->needs_update = FALSE;
-  gdkdev->claimed = FALSE;
-  gdkdev->button_state = 0;
-
-  class = device->inputclassinfo;
-  for (i=0;i<device->num_classes;i++) 
-    {
-      switch (class->class) {
-      case ButtonClass:
-       {
-         break;
-       }
-      case KeyClass:
-       {
-         XKeyInfo *xki = (XKeyInfo *)class;
-         /* Hack to catch XFree86 3.3.1 bug. Other devices better
-          * not have exactly 25 keys... 
-          */
-         if ((xki->min_keycode == 8) && (xki->max_keycode == 32))
-           {
-             gdkdev->info.num_keys = 32;
-             gdkdev->min_keycode = 1;
-           }
-         else
-           {
-             gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
-             gdkdev->min_keycode = xki->min_keycode;
-           }
-         gdkdev->info.keys = g_new (GdkDeviceKey, gdkdev->info.num_keys);
-
-         for (j=0; j<gdkdev->info.num_keys; j++)
-           {
-             gdkdev->info.keys[j].keyval = 0;
-             gdkdev->info.keys[j].modifiers = 0;
-           }
-
-         break;
-       }
-      case ValuatorClass:
-       {
-         XValuatorInfo *xvi = (XValuatorInfo *)class;
-         gdkdev->info.num_axes = xvi->num_axes;
-         gdkdev->axes = g_new(GdkAxisInfo, xvi->num_axes);
-         gdkdev->info.axes = g_new(GdkAxisUse, xvi->num_axes);
-         for (j=0;j<xvi->num_axes;j++)
-           {
-             gdkdev->axes[j].resolution = 
-               gdkdev->axes[j].xresolution = xvi->axes[j].resolution;
-             gdkdev->axes[j].min_value =
-               gdkdev->axes[j].xmin_value = xvi->axes[j].min_value;
-             gdkdev->axes[j].max_value =
-               gdkdev->axes[j].xmax_value = xvi->axes[j].max_value;
-             gdkdev->info.axes[j] = GDK_AXIS_IGNORE;
-           }
-         j=0;
-         if (j<xvi->num_axes)
-           gdkdev->info.axes[j++] = GDK_AXIS_X;
-         if (j<xvi->num_axes)
-           gdkdev->info.axes[j++] = GDK_AXIS_Y;
-         if (j<xvi->num_axes)
-           gdkdev->info.axes[j++] = GDK_AXIS_PRESSURE;
-         if (j<xvi->num_axes)
-           gdkdev->info.axes[j++] = GDK_AXIS_XTILT;
-         if (j<xvi->num_axes)
-           gdkdev->info.axes[j++] = GDK_AXIS_YTILT;
-         
-         /* set up reverse lookup on axis use */
-         for (j=GDK_AXIS_IGNORE;j<GDK_AXIS_LAST;j++)
-           gdkdev->axis_for_use[j] = -1;
-         
-         for (j=0;j<xvi->num_axes;j++)
-           if (gdkdev->info.axes[j] != GDK_AXIS_IGNORE)
-             gdkdev->axis_for_use[gdkdev->info.axes[j]] = j;
-                      
-         break;
-       }
-      }
-      class = (XAnyClassPtr)(((char *)class) + class->length);
-    }
-  /* return NULL if no axes */
-  if (!gdkdev->info.num_axes || !gdkdev->axes ||
-      (!include_core && device->use == IsXPointer))
-    {
-      g_free(gdkdev->info.name);
-      if (gdkdev->axes)
-       g_free(gdkdev->axes);
-      if (gdkdev->info.keys)
-       g_free(gdkdev->info.keys);
-      g_free(gdkdev);
-      return NULL;
-    }
-
-  if (device->use != IsXPointer)
-    {
-      int error_warn = gdk_error_warnings;
-
-      gdk_error_warnings = 0;
-      gdk_error_code = 0;
-      gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
-      gdk_error_warnings = error_warn;
-
-      /* return NULL if device is not ready */
-      if (gdk_error_code)
-       {
-         g_free (gdkdev->info.name);
-         if (gdkdev->axes)
-           g_free (gdkdev->axes);
-         if (gdkdev->info.keys)
-           g_free (gdkdev->info.keys);
-         if (gdkdev->info.axes)
-           g_free (gdkdev->info.axes);
-         g_free (gdkdev);
-
-         return NULL;
-       }
-    }
-
-  gdkdev->buttonpress_type = 0;
-  gdkdev->buttonrelease_type = 0;
-  gdkdev->keypress_type = 0;
-  gdkdev->keyrelease_type = 0;
-  gdkdev->motionnotify_type = 0;
-  gdkdev->proximityin_type = 0;
-  gdkdev->proximityout_type = 0;
-  gdkdev->changenotify_type = 0;
-
-  return gdkdev;
-}
-
-static void
-gdk_input_common_find_events(GdkWindow *window,
-                            GdkDevicePrivate *gdkdev,
-                            gint mask,
-                            XEventClass *classes,
-                            int *num_classes)
-{
-  gint i;
-  XEventClass class;
-  
-  i = 0;
-  /* We have to track press and release events in pairs to keep
-     track of button state correctly and implement grabbing for
-     the gxi support */
-  if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
-    {
-      DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
-                            class);
-      if (class != 0)
-         classes[i++] = class;
-      DeviceButtonPressGrab (gdkdev->xdevice, 0, class);
-      if (class != 0)
-         classes[i++] = class;
-      DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
-                          class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_POINTER_MOTION_MASK)
-    {
-      DeviceMotionNotify  (gdkdev->xdevice, gdkdev->motionnotify_type, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  else
-    if (mask & (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
-               GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
-               GDK_POINTER_MOTION_HINT_MASK))
-      {
-       /* Make sure gdkdev->motionnotify_type is set */
-       DeviceMotionNotify  (gdkdev->xdevice, gdkdev->motionnotify_type, class);
-      }
-  if (mask & GDK_BUTTON1_MOTION_MASK)
-    {
-      DeviceButton1Motion  (gdkdev->xdevice, 0, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_BUTTON2_MOTION_MASK)
-    {
-      DeviceButton2Motion  (gdkdev->xdevice, 0, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_BUTTON3_MOTION_MASK)
-    {
-      DeviceButton3Motion  (gdkdev->xdevice, 0, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_BUTTON_MOTION_MASK)
-    {
-      DeviceButtonMotion  (gdkdev->xdevice, 0, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_POINTER_MOTION_HINT_MASK)
-    {
-      /* We'll get into trouble if the macros change, but at least we'll
-        know about it, and we avoid warnings now */
-      DevicePointerMotionHint (gdkdev->xdevice, 0, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_KEY_PRESS_MASK)
-    {
-      DeviceKeyPress (gdkdev->xdevice, gdkdev->keypress_type, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_KEY_RELEASE_MASK)
-    {
-      DeviceKeyRelease (gdkdev->xdevice, gdkdev->keyrelease_type, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_PROXIMITY_IN_MASK)
-    {
-      ProximityIn   (gdkdev->xdevice, gdkdev->proximityin_type, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-  if (mask & GDK_PROXIMITY_OUT_MASK)
-    {
-      ProximityOut  (gdkdev->xdevice, gdkdev->proximityout_type, class);
-      if (class != 0)
-         classes[i++] = class;
-    }
-
-  *num_classes = i;
-}
-
-static void
-gdk_input_common_select_events(GdkWindow *window,
-                              GdkDevicePrivate *gdkdev)
-{
-  XEventClass classes[GDK_MAX_DEVICE_CLASSES];
-  gint num_classes;
-
-  if (gdkdev->info.mode == GDK_MODE_DISABLED)
-    gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes);
-  else
-    gdk_input_common_find_events(window, gdkdev, 
-                                ((GdkWindowPrivate *)window)->extension_events,
-                                classes, &num_classes);
-  
-  XSelectExtensionEvent (gdk_display,
-                        GDK_WINDOW_XWINDOW(window),
-                        classes, num_classes);
-}
-
-gint 
-gdk_input_common_init(gint include_core)
-{
-  char **extensions;
-  XDeviceInfo   *devices;
-  int num_devices;
-  int num_extensions, loop;
-  Display *display = gdk_display;
-
-  /* Init global vars */
-  gdk_window_get_geometry(NULL,        /* use root window */
-                         NULL,NULL,
-                         &gdk_input_root_width,&gdk_input_root_height, 
-                         NULL);
-
-  /* Init XInput extension */
-  
-  extensions = XListExtensions(display, &num_extensions);
-  for (loop = 0; loop < num_extensions &&
-        (strcmp(extensions[loop], "XInputExtension") != 0); loop++);
-  XFreeExtensionList(extensions);
-  gdk_input_devices = NULL;
-  if (loop < num_extensions)
-    {
-      /* XInput extension found */
-
-      devices = XListInputDevices(display, &num_devices);
-  
-      for(loop=0; loop<num_devices; loop++)
-       {
-         GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
-                                                     include_core);
-         if (gdkdev)
-           gdk_input_devices = g_list_append(gdk_input_devices, gdkdev);
-       }
-      XFreeDeviceList(devices);
-    }
-
-  gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
-
-  return TRUE;
-}
-
-static void
-gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
-                                GdkInputWindow *input_window,
-                                gint *axis_data,
-                                gdouble *x, gdouble *y, gdouble *pressure,
-                                gdouble *xtilt, gdouble *ytilt)
-{
-  GdkDrawablePrivate *drawable_priv;
-
-  int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis;
-
-  double device_width, device_height;
-  double x_offset, y_offset, x_scale, y_scale;
-
-  drawable_priv = (GdkDrawablePrivate *) input_window->window;
-
-  x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
-  y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
-  pressure_axis = gdkdev->axis_for_use[GDK_AXIS_PRESSURE];
-  xtilt_axis = gdkdev->axis_for_use[GDK_AXIS_XTILT];
-  ytilt_axis = gdkdev->axis_for_use[GDK_AXIS_YTILT];
-
-  device_width = gdkdev->axes[x_axis].max_value - 
-                  gdkdev->axes[x_axis].min_value;
-  device_height = gdkdev->axes[y_axis].max_value - 
-                    gdkdev->axes[y_axis].min_value;
-
-  if (gdkdev->info.mode == GDK_MODE_SCREEN) 
-    {
-      x_scale = gdk_input_root_width / device_width;
-      y_scale = gdk_input_root_height / device_height;
-
-      x_offset = - input_window->root_x;
-      y_offset = - input_window->root_y;
-    }
-  else                         /* GDK_MODE_WINDOW */
-    {
-      double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /
-       (device_width*gdkdev->axes[x_axis].resolution);
-
-      if (device_aspect * drawable_priv->width >= drawable_priv->height)
-       {
-         /* device taller than window */
-         x_scale = drawable_priv->width / device_width;
-         y_scale = (x_scale * gdkdev->axes[x_axis].resolution)
-           / gdkdev->axes[y_axis].resolution;
-
-         x_offset = 0;
-         y_offset = -(device_height * y_scale - 
-                              drawable_priv->height)/2;
-       }
-      else
-       {
-         /* window taller than device */
-         y_scale = drawable_priv->height / device_height;
-         x_scale = (y_scale * gdkdev->axes[y_axis].resolution)
-           / gdkdev->axes[x_axis].resolution;
-
-         y_offset = 0;
-         x_offset = - (device_width * x_scale - drawable_priv->width)/2;
-       }
-    }
-  
-  if (x) *x = x_offset + x_scale*axis_data[x_axis];
-  if (y) *y = y_offset + y_scale*axis_data[y_axis];
-
-  if (pressure)
-    {
-      if (pressure_axis != -1)
-       *pressure = ((double)axis_data[pressure_axis] 
-                    - gdkdev->axes[pressure_axis].min_value) 
-         / (gdkdev->axes[pressure_axis].max_value 
-            - gdkdev->axes[pressure_axis].min_value);
-      else
-       *pressure = 0.5;
-    }
-
-  if (xtilt)
-    {
-      if (xtilt_axis != -1)
-       {
-         *xtilt = 2. * (double)(axis_data[xtilt_axis] - 
-                                (gdkdev->axes[xtilt_axis].min_value +
-                                 gdkdev->axes[xtilt_axis].max_value)/2) /
-           (gdkdev->axes[xtilt_axis].max_value -
-            gdkdev->axes[xtilt_axis].min_value);
-       }
-      else *xtilt = 0;
-    }
-  
-  if (ytilt)
-    {
-      if (ytilt_axis != -1)
-       {
-         *ytilt = 2. * (double)(axis_data[ytilt_axis] - 
-                                (gdkdev->axes[ytilt_axis].min_value +
-                                 gdkdev->axes[ytilt_axis].max_value)/2) /
-           (gdkdev->axes[ytilt_axis].max_value -
-            gdkdev->axes[ytilt_axis].min_value);
-       }
-      else
-       *ytilt = 0;
-    }
-}
-
-/* combine the state of the core device and the device state
-   into one - for now we do this in a simple-minded manner -
-   we just take the keyboard portion of the core device and
-   the button portion (all of?) the device state.
-   Any button remapping should go on here. */
-static guint
-gdk_input_translate_state(guint state, guint device_state)
-{
-  return device_state | (state & 0xFF);
-}
-
-static gint 
-gdk_input_common_other_event (GdkEvent *event, 
-                             XEvent *xevent, 
-                             GdkInputWindow *input_window,
-                             GdkDevicePrivate *gdkdev)
-{
-  if ((xevent->type == gdkdev->buttonpress_type) ||
-      (xevent->type == gdkdev->buttonrelease_type)) 
-    {
-      XDeviceButtonEvent *xdbe = (XDeviceButtonEvent *)(xevent);
-
-      if (xdbe->type == gdkdev->buttonpress_type)
-       {
-         event->button.type = GDK_BUTTON_PRESS;
-         gdkdev->button_state |= 1 << xdbe->button;
-       }
-      else
-       {
-         event->button.type = GDK_BUTTON_RELEASE;
-         gdkdev->button_state &= ~(1 << xdbe->button);
-       }
-      event->button.window = input_window->window;
-      event->button.time = xdbe->time;
-      event->button.source = gdkdev->info.source;
-      event->button.deviceid = xdbe->deviceid;
-
-      gdk_input_translate_coordinates (gdkdev,input_window, xdbe->axis_data,
-                                      &event->button.x,&event->button.y,
-                                      &event->button.pressure,
-                                      &event->button.xtilt, 
-                                      &event->button.ytilt);
-      event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
-      event->button.button = xdbe->button;
-
-      GDK_NOTE (EVENTS,
-       g_print ("button %s:\t\twindow: %ld  device: %ld  x,y: %f %f  button: %d\n",
-                (event->button.type == GDK_BUTTON_PRESS) ? "press" : "release",
-                xdbe->window,
-                xdbe->deviceid,
-                event->button.x, event->button.y,
-                xdbe->button));
-
-      return TRUE;
-  }
-
-  if ((xevent->type == gdkdev->keypress_type) ||
-      (xevent->type == gdkdev->keyrelease_type))
-    {
-      XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
-
-      GDK_NOTE (EVENTS,
-       g_print ("device key %s:\twindow: %ld  device: %ld  keycode: %d\n",
-                (event->key.type == GDK_KEY_PRESS) ? "press" : "release",
-                xdke->window,
-                xdke->deviceid,
-                xdke->keycode));
-
-      if (xdke->keycode < gdkdev->min_keycode ||
-         xdke->keycode >= gdkdev->min_keycode + gdkdev->info.num_keys)
-       {
-         g_warning ("Invalid device key code received");
-         return FALSE;
-       }
-      
-      event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
-
-      if (event->key.keyval == 0) 
-       {
-         GDK_NOTE (EVENTS,
-           g_print ("\t\ttranslation - NONE\n"));
-         
-         return FALSE;
-       }
-
-      event->key.type = (xdke->type == gdkdev->keypress_type) ?
-       GDK_KEY_PRESS : GDK_KEY_RELEASE;
-
-      event->key.window = input_window->window;
-      event->key.time = xdke->time;
-
-      event->key.state = gdk_input_translate_state(xdke->state, xdke->device_state)
-       | gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].modifiers;
-
-      /* Add a string translation for the key event */
-      if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF))
-       {
-         event->key.length = 1;
-         event->key.string = g_new (gchar, 2);
-         event->key.string[0] = (gchar)event->key.keyval;
-         event->key.string[1] = 0;
-       }
-      else
-       {
-         event->key.length = 0;
-         event->key.string = g_new0 (gchar, 1);
-       }
-
-      GDK_NOTE (EVENTS,
-       g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
-                event->key.keyval,
-                event->key.state));
-
-      return TRUE;
-    }
-
-  if (xevent->type == gdkdev->motionnotify_type) 
-    {
-      XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
-
-      gdk_input_translate_coordinates(gdkdev,input_window,xdme->axis_data,
-                                     &event->motion.x,&event->motion.y,
-                                     &event->motion.pressure,
-                                     &event->motion.xtilt, 
-                                     &event->motion.ytilt);
-
-      event->motion.type = GDK_MOTION_NOTIFY;
-      event->motion.window = input_window->window;
-      event->motion.time = xdme->time;
-      event->motion.deviceid = xdme->deviceid;
-      event->motion.state = gdk_input_translate_state(xdme->state,
-                                                     xdme->device_state);
-      event->motion.is_hint = xdme->is_hint;
-      event->motion.source = gdkdev->info.source;
-      event->motion.deviceid = xdme->deviceid;
-
-      GDK_NOTE (EVENTS,
-       g_print ("motion notify:\t\twindow: %ld  device: %ld  x,y: %f %f  state %#4x  hint: %s\n",
-                xdme->window,
-                xdme->deviceid,
-                event->motion.x, event->motion.y,
-                event->motion.state,
-                (xdme->is_hint) ? "true" : "false"));
-      
-      
-      return TRUE;
-    }
-
-  if (xevent->type == gdkdev->proximityin_type ||
-      xevent->type == gdkdev->proximityout_type)
-    {
-      XProximityNotifyEvent *xpne = (XProximityNotifyEvent *)(xevent);
-
-      event->proximity.type = (xevent->type == gdkdev->proximityin_type)?
-       GDK_PROXIMITY_IN:GDK_PROXIMITY_OUT;
-      event->proximity.window = input_window->window;
-      event->proximity.time = xpne->time;
-      event->proximity.source = gdkdev->info.source;
-      event->proximity.deviceid = xpne->deviceid;
-      
-      return TRUE;
-  }
-
-  return -1;                   /* wasn't one of our event types */
-}
-
-static void
-gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
-{
-  int i;
-  GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
-  g_return_if_fail (gdkdev != NULL);
-
-  for (i=GDK_AXIS_IGNORE;i<GDK_AXIS_LAST;i++)
-    {
-      gdkdev->axis_for_use[i] = -1;
-    }
-
-  for (i=0;i<gdkdev->info.num_axes;i++)
-    {
-      gdkdev->info.axes[i] = axes[i];
-      gdkdev->axis_for_use[axes[i]] = i;
-    }
-}
-
-void gdk_input_common_set_key (guint32 deviceid,
-                              guint   index,
-                              guint   keyval,
-                              GdkModifierType modifiers)
-{
-  GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
-  
-  gdkdev = gdk_input_find_device (deviceid);
-  g_return_if_fail (gdkdev != NULL);
-  g_return_if_fail (index < gdkdev->info.num_keys);
-
-  gdkdev->info.keys[index].keyval = keyval;
-  gdkdev->info.keys[index].modifiers = modifiers;
-}
-
-static GdkTimeCoord *
-gdk_input_common_motion_events (GdkWindow *window,
-                               guint32 deviceid,
-                               guint32 start,
-                               guint32 stop,
-                               gint *nevents_return)
-{
-  GdkTimeCoord *coords;
-  XDeviceTimeCoord *device_coords;
-  GdkInputWindow *input_window;
-  GdkDevicePrivate *gdkdev;
-
-  int mode_return;
-  int axis_count_return;
-  int i;
-
-  gdkdev = gdk_input_find_device (deviceid);
-  input_window = gdk_input_window_find (window);
-
-  g_return_val_if_fail (gdkdev != NULL, NULL);
-  g_return_val_if_fail (gdkdev->xdevice != NULL, NULL);
-  g_return_val_if_fail (input_window != NULL, NULL);
-
-  device_coords = XGetDeviceMotionEvents (gdk_display,
-                                         gdkdev->xdevice,
-                                         start, stop,
-                                         nevents_return, &mode_return,
-                                         &axis_count_return);
-
-  if (device_coords)
-    {
-      coords = g_new (GdkTimeCoord, *nevents_return);
-      
-      for (i=0; i<*nevents_return; i++)
-       {
-         gdk_input_translate_coordinates (gdkdev, input_window,
-                                          device_coords[i].data,
-                                          &coords[i].x, &coords[i].y,
-                                          &coords[i].pressure,
-                                          &coords[i].xtilt, &coords[i].ytilt);
-       }
-      XFreeDeviceMotionEvents (device_coords);
-
-      return coords;
-    }
-  else
-    return NULL;
-}
-
-static void 
-gdk_input_common_get_pointer     (GdkWindow       *window,
-                                 guint32          deviceid,
-                                 gdouble         *x,
-                                 gdouble         *y,
-                                 gdouble         *pressure,
-                                 gdouble         *xtilt,
-                                 gdouble         *ytilt,
-                                 GdkModifierType *mask)
-{
-  GdkDevicePrivate *gdkdev;
-  GdkInputWindow *input_window;
-  XDeviceState *state;
-  XInputClass *input_class;
-  gint x_int, y_int;
-  gint i;
-
-  /* we probably need to get the mask in any case */
-
-  if (deviceid == GDK_CORE_POINTER)
-    {
-      gdk_window_get_pointer (window, &x_int, &y_int, mask);
-      if (x) *x = x_int;
-      if (y) *y = y_int;
-      if (pressure) *pressure = 0.5;
-      if (xtilt) *xtilt = 0;
-      if (ytilt) *ytilt = 0;
-    }
-  else
-    {
-      if (mask)
-       gdk_window_get_pointer (window, NULL, NULL, mask);
-      
-      gdkdev = gdk_input_find_device (deviceid);
-      input_window = gdk_input_window_find (window);
-
-      g_return_if_fail (gdkdev != NULL);
-      g_return_if_fail (gdkdev->xdevice != NULL);
-      g_return_if_fail (input_window != NULL);
-
-      state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
-      input_class = state->data;
-      for (i=0; i<state->num_classes; i++)
-       {
-         switch (input_class->class)
-           {
-           case ValuatorClass:
-             gdk_input_translate_coordinates (gdkdev, input_window,
-                                              ((XValuatorState *)input_class)->valuators,
-                                              x, y, pressure,
-                                              xtilt, ytilt);
-                                                      
-                                                      
-               break;
-           case ButtonClass:
-             if (mask)
-               {
-                 *mask &= 0xFF;
-                 if (((XButtonState *)input_class)->num_buttons > 0)
-                   *mask |= ((XButtonState *)input_class)->buttons[0] << 7;
-                 /* GDK_BUTTON1_MASK = 1 << 8, and button n is stored
-                  * in bit 1<<(n%8) in byte n/8. n = 1,2,... */
-               }
-             break;
-           }
-         input_class = (XInputClass *)(((char *)input_class)+input_class->length);
-       }
-    }
-}
-
-#endif
diff --git a/gdk/gdkinputgxi.h b/gdk/gdkinputgxi.h
deleted file mode 100644 (file)
index 773a043..0000000
+++ /dev/null
@@ -1,649 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#ifdef XINPUT_GXI
-
-/* #define DEBUG_SWITCHING */
-
-#include <gxid_lib.h>
-
-/* Forward declarations */
-static void gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev);
-static gint gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode);
-static gint gdk_input_is_extension_device (guint32 deviceid);
-static void gdk_input_gxi_configure_event (XConfigureEvent *xevent, 
-                                          GdkWindow *window);
-static void gdk_input_gxi_enter_event (XCrossingEvent *xevent, 
-                                      GdkWindow *window);
-static gint gdk_input_gxi_other_event (GdkEvent *event, 
-                                      XEvent *xevent, 
-                                      GdkWindow *window);
-static void gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev);
-
-static gint gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent);
-static gint gdk_input_gxi_enable_window (GdkWindow *window, 
-                                        GdkDevicePrivate *gdkdev);
-static gint gdk_input_gxi_disable_window (GdkWindow *window, 
-                                         GdkDevicePrivate *gdkdev);
-static Window gdk_input_find_root_child(Display *dpy, Window w);
-static void gdk_input_compute_obscuring(GdkInputWindow *input_window);
-static gint gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x, 
-                                 gdouble y);
-static GdkTimeCoord *gdk_input_gxi_motion_events (GdkWindow *window,
-                                                 guint32 deviceid,
-                                                 guint32 start,
-                                                 guint32 stop,
-                                                 gint *nevents_return);
-static void gdk_input_gxi_get_pointer (GdkWindow       *window,
-                                      guint32     deviceid,
-                                      gdouble         *x,
-                                      gdouble         *y,
-                                      gdouble         *pressure,
-                                      gdouble         *xtilt,
-                                      gdouble         *ytilt,
-                                      GdkModifierType *mask);
-static gint gdk_input_gxi_grab_pointer (GdkWindow *     window,
-                                       gint            owner_events,
-                                       GdkEventMask    event_mask,
-                                       GdkWindow *     confine_to,
-                                       guint32         time);
-static void gdk_input_gxi_ungrab_pointer (guint32 time);
-
-/* Local variables */
-
-static GdkDevicePrivate *gdk_input_current_device;
-static GdkDevicePrivate *gdk_input_core_pointer;
-
-void
-gdk_input_init(void)
-{
-  GList *tmp_list;
-  
-  gdk_input_vtable.set_mode           = gdk_input_gxi_set_mode;
-  gdk_input_vtable.set_axes           = gdk_input_common_set_axes;
-  gdk_input_vtable.set_key            = gdk_input_common_set_key;
-  gdk_input_vtable.motion_events      = gdk_input_gxi_motion_events;
-  gdk_input_vtable.get_pointer       = gdk_input_gxi_get_pointer;
-  gdk_input_vtable.grab_pointer              = gdk_input_gxi_grab_pointer;
-  gdk_input_vtable.ungrab_pointer     = gdk_input_gxi_ungrab_pointer;
-  gdk_input_vtable.configure_event    = gdk_input_gxi_configure_event;
-  gdk_input_vtable.enter_event        = gdk_input_gxi_enter_event;
-  gdk_input_vtable.other_event        = gdk_input_gxi_other_event;
-  gdk_input_vtable.window_none_event  = gdk_input_gxi_window_none_event;
-  gdk_input_vtable.enable_window      = gdk_input_gxi_enable_window;
-  gdk_input_vtable.disable_window     = gdk_input_gxi_disable_window;
-
-  gdk_input_ignore_core = FALSE;
-  gdk_input_core_pointer = NULL;
-
-  if (!gdk_input_gxid_host) 
-    {
-      gdk_input_gxid_host = getenv("GXID_HOST");
-    }
-  if (!gdk_input_gxid_port) 
-    {
-      char *t = getenv("GXID_PORT");
-      if (t)
-       gdk_input_gxid_port = atoi(t);
-    }
-  
-  gdk_input_common_init(TRUE);
-
-  /* find initial core pointer */
-  
-  for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next) 
-    {
-      GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)tmp_list->data;
-      if (gdk_input_is_extension_device(gdkdev->info.deviceid))
-       {
-         gdk_input_gxi_select_notify (gdkdev);
-       }
-      else
-       {
-         if (gdkdev->info.deviceid != GDK_CORE_POINTER)
-           gdk_input_core_pointer = gdkdev;
-       }
-    }
-}
-
-static void
-gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev)
-{
-  XEventClass class;
-
-  ChangeDeviceNotify  (gdkdev->xdevice, gdkdev->changenotify_type, class);
-
-  XSelectExtensionEvent (gdk_display, gdk_root_window, &class, 1);
-}
-
-/* Set the core pointer. Device should already be enabled. */
-static gint
-gdk_input_gxi_set_core_pointer(GdkDevicePrivate *gdkdev)
-{
-  int x_axis,y_axis;
-
-  g_return_val_if_fail(gdkdev->xdevice,FALSE);
-
-  x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
-  y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
-
-  g_return_val_if_fail(x_axis != -1 && y_axis != -1,FALSE);
-
-  /* core_pointer might not be up to date so we check with the server
-     before change the pointer */
-
-  if ( !gdk_input_is_extension_device(gdkdev->info.deviceid) )
-    {
-#if 0
-      if (gdkdev != gdk_input_core_pointer)
-       g_warning("core pointer inconsistency");
-#endif      
-      return TRUE;
-    }
-
-  if ( XChangePointerDevice(gdk_display,gdkdev->xdevice, x_axis, y_axis) 
-       != Success )
-    {
-      return FALSE;
-    }
-  else
-    {
-      gdk_input_gxi_update_device (gdk_input_core_pointer);
-      gdk_input_core_pointer = gdkdev;
-      return TRUE;
-    }
-}
-
-
-/* FIXME, merge with gdk_input_xfree_set_mode */
-
-static gint
-gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode)
-{
-  GList *tmp_list;
-  GdkDevicePrivate *gdkdev;
-  GdkInputMode old_mode;
-  GdkInputWindow *input_window;
-
-  gdkdev = gdk_input_find_device(deviceid);
-  g_return_val_if_fail (gdkdev != NULL,FALSE);
-  old_mode = gdkdev->info.mode;
-
-  if (gdkdev->info.mode == mode)
-    return TRUE;
-  
-  gdkdev->info.mode = mode;
-
-  if (old_mode != GDK_MODE_DISABLED)
-    {
-      for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
-       {
-         input_window = (GdkInputWindow *)tmp_list->data;
-         if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
-           gdk_input_disable_window (input_window->window, gdkdev);
-       }
-    }
-  
-  if (mode != GDK_MODE_DISABLED)
-    {
-      for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
-       {
-         input_window = (GdkInputWindow *)tmp_list->data;
-         if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
-           if (!gdk_input_enable_window(input_window->window, gdkdev))
-             {
-               gdk_input_set_mode(deviceid, old_mode);
-               return FALSE;
-             }
-       }
-    }
-
-  return TRUE;
-
-}
-
-gint
-gdk_input_is_extension_device (guint32 deviceid)
-{
-  XDeviceInfo   *devices;
-  int num_devices, loop;
-
-  if (deviceid == GDK_CORE_POINTER)
-    return FALSE;
-  
-  devices = XListInputDevices(gdk_display, &num_devices);
-  for(loop=0; loop<num_devices; loop++)
-    {
-      if ((devices[loop].id == deviceid) && (devices[loop].use == IsXExtensionDevice)) 
-       {
-         XFreeDeviceList(devices);
-         return TRUE;
-       }
-    }
-
-  XFreeDeviceList(devices);
-  return FALSE;
-}
-
-static void
-gdk_input_gxi_configure_event (XConfigureEvent *xevent, GdkWindow *window)
-{
-  GdkInputWindow *input_window;
-  gint root_x, root_y;
-
-  input_window = gdk_input_window_find(window);
-  g_return_if_fail (input_window != NULL);
-
-  gdk_input_get_root_relative_geometry(gdk_display,GDK_WINDOW_XWINDOW(window),
-                                &root_x, &root_y, NULL, NULL);
-  input_window->root_x = root_x;
-  input_window->root_y = root_y;
-  gdk_input_compute_obscuring(input_window);
-}
-
-static void
-gdk_input_gxi_enter_event (XCrossingEvent *xevent, GdkWindow *window)
-{
-  GdkInputWindow *input_window;
-
-  input_window = gdk_input_window_find(window);
-  g_return_if_fail (input_window != NULL);
-
-  gdk_input_compute_obscuring(input_window);
-}
-
-static gint 
-gdk_input_gxi_other_event (GdkEvent *event, 
-                          XEvent *xevent, 
-                          GdkWindow *window)
-{
-  GdkInputWindow *input_window;
-
-  GdkDevicePrivate *gdkdev;
-  gint return_val;
-
-  input_window = gdk_input_window_find(window);
-  g_return_val_if_fail (window != NULL, -1);
-
-  /* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
-     but it's potentially faster than scanning through the types of
-     every device. If we were deceived, then it won't match any of
-     the types for the device anyways */
-  gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
-
-  if (!gdkdev) {
-    return -1;                 /* we don't handle it - not an XInput event */
-  }
-
-  if (gdkdev->info.mode == GDK_MODE_DISABLED ||
-      input_window->mode == GDK_EXTENSION_EVENTS_CURSOR)
-    return FALSE;
-  
-  if (gdkdev != gdk_input_current_device &&
-      xevent->type != gdkdev->changenotify_type)
-    {
-      gdk_input_current_device = gdkdev;
-    }
-
-  return_val = gdk_input_common_other_event (event, xevent, 
-                                            input_window, gdkdev);
-
-  if (return_val > 0 && event->type == GDK_MOTION_NOTIFY &&
-      (!gdkdev->button_state) && (!input_window->grabbed) &&
-      ((event->motion.x < 0) || (event->motion.y < 0) ||
-       (event->motion.x > ((GdkWindowPrivate *)window)->width) || 
-       (event->motion.y > ((GdkWindowPrivate *)window)->height) ||
-       gdk_input_is_obscured(input_window,event->motion.x,event->motion.y)))
-    {
-#ifdef DEBUG_SWITCHING
-      g_print("gdkinput: Setting core pointer to %d on motion at (%f,%f)\n",
-             gdkdev->info.deviceid,event->motion.x,event->motion.y);
-      g_print("   window geometry is: %dx%d\n",
-             ((GdkWindowPrivate *)window)->width,
-             ((GdkWindowPrivate *)window)->height);
-#endif      
-      gdk_input_gxi_set_core_pointer(gdkdev);
-      return FALSE;
-    }
-  else
-    return return_val;
-
-}
-
-static void
-gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev)
-{
-  GList *t;
-
-  if (gdk_input_is_extension_device (gdkdev->info.deviceid))
-    {
-      if (!gdkdev->xdevice)
-       {
-         gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
-         gdk_input_gxi_select_notify (gdkdev);
-         gdkdev->needs_update = 1;
-       }
-      if (gdkdev->needs_update && gdkdev->xdevice)
-       {
-         for (t = gdk_input_windows; t; t = t->next)
-           gdk_input_common_select_events (((GdkInputWindow *)t->data)->window,
-                                        gdkdev);
-         gdkdev->needs_update = 0;
-       }
-    }
-}
-
-static gint 
-gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent)
-{
-  GdkDevicePrivate *gdkdev = 
-    gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
-
-  if (!gdkdev) {
-    return -1;                 /* we don't handle it - not an XInput event */
-  }
-
-  if (xevent->type == gdkdev->changenotify_type)
-    {
-      if (gdk_input_core_pointer != gdkdev)
-       {
-#ifdef DEBUG_SWITCHING
-         g_print("ChangeNotify from %d to %d:\n",
-                 gdk_input_core_pointer->info.deviceid,
-                 gdkdev->info.deviceid);
-#endif
-         gdk_input_gxi_update_device (gdk_input_core_pointer);
-         gdk_input_core_pointer = gdkdev;
-       }
-    }
-               
-  return FALSE;
-}
-
-static gint
-gdk_input_gxi_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
-{
-  GdkInputWindow *input_window;
-
-  input_window = gdk_input_window_find (window);
-  g_return_val_if_fail (input_window != NULL, FALSE);
-
-  if (!gdkdev->claimed)
-    {
-      if (gxid_claim_device(gdk_input_gxid_host, gdk_input_gxid_port,
-                           gdkdev->info.deviceid,
-                           GDK_WINDOW_XWINDOW(window), FALSE) !=
-         GXID_RETURN_OK)
-       {
-         g_warning("Could not get device (is gxid running?)\n");
-         return FALSE;
-       }
-      gdkdev->claimed = TRUE;
-    }
-
-  if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
-    gdk_input_common_select_events(window, gdkdev);
-  else
-    gdkdev->needs_update = TRUE;
-  
-  return TRUE;
-}
-
-static gint
-gdk_input_gxi_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
-{
-  GdkInputWindow *input_window;
-
-  input_window = gdk_input_window_find (window);
-  g_return_val_if_fail (input_window != NULL, FALSE);
-
-  if (gdkdev->claimed)
-    {
-      gxid_release_device(gdk_input_gxid_host, gdk_input_gxid_port,
-                         gdkdev->info.deviceid,
-                         GDK_WINDOW_XWINDOW(window));
-
-      gdkdev->claimed = FALSE;
-    }
-
-  if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
-    gdk_input_common_select_events(window, gdkdev);
-  else
-    gdkdev->needs_update = TRUE;
-  
-  return TRUE;
-}
-
-static gint
-gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x, gdouble y)
-{
-  int i;
-  for (i=0;i<input_window->num_obscuring;i++)
-    {
-      GdkRectangle *rect = &input_window->obscuring[i];
-      if ((x >= rect->x) &&
-         (y >= rect->y) &&
-         (x < rect->x + rect->width) &&
-         (y < rect->y + rect->height))
-       return TRUE;
-    }
-  return FALSE;
-}
-
-/* If this routine needs fixing, the corresponding routine
-   in gxid.c will need it too. */
-
-static Window 
-gdk_input_find_root_child(Display *dpy, Window w)
-{
-  Window root,parent;
-  Window *children;
-  int nchildren;
-
-  parent = w;
-  do 
-    {
-      w = parent;
-      XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
-      if (children) XFree(children);
-    } 
-  while (parent != root);
-  
-  return w;
-}
-
-void
-gdk_input_compute_obscuring(GdkInputWindow *input_window)
-{
-  int i;
-  int x,y,width,height;
-  int xc,yc,widthc,heightc,border_widthc,depthc;
-
-  Window root,parent;
-  Window *children;
-  int nchildren;
-
-  Window w = GDK_WINDOW_XWINDOW(input_window->window);
-  Window root_child = gdk_input_find_root_child(gdk_display,w);
-  gdk_input_get_root_relative_geometry(gdk_display,w,&x,&y,&width,&height);
-
-  input_window->root_x = x;
-  input_window->root_y = y;
-
-  XQueryTree(gdk_display,GDK_ROOT_WINDOW(),
-            &root,&parent,&children,&nchildren);
-
-
-  if (input_window->obscuring)
-    g_free(input_window->obscuring);
-  input_window->obscuring = 0;
-  input_window->num_obscuring = 0;
-
-  for (i=0;i<nchildren;i++)
-    if (children[i] == root_child)
-      break;
-
-  if (i>=nchildren-1)
-    {
-      if (nchildren)
-       XFree(children);
-      return;
-    }
-
-  input_window->obscuring = g_new(GdkRectangle,(nchildren-i-1));
-
-  for (i=i+1;i<nchildren;i++)
-    {
-      int xmin, xmax, ymin, ymax;
-      XGetGeometry(gdk_display,children[i],&root,&xc,&yc,&widthc,&heightc,
-                  &border_widthc, &depthc);
-      xmin = xc>x ? xc : x;
-      xmax = (xc+widthc)<(x+width) ? xc+widthc : x+width;
-      ymin = yc>y ? yc : y;
-      ymax = (yc+heightc)<(y+height) ? yc+heightc : y+height;
-      if ((xmin < xmax) && (ymin < ymax))
-       {
-         XWindowAttributes attributes;
-         XGetWindowAttributes(gdk_display,children[i],&attributes);
-         if (attributes.map_state == IsViewable)
-           {
-             GdkRectangle *rect = &input_window->obscuring[input_window->num_obscuring];
-             
-             /* we store the whole window, not just the obscuring part */
-             rect->x = xc - x;
-             rect->y = yc - y;
-             rect->width = widthc;
-             rect->height = heightc;
-             input_window->num_obscuring++;
-           }
-       }
-    }
-
-  if (nchildren)
-    XFree(children);
-}
-
-static void 
-gdk_input_gxi_get_pointer     (GdkWindow       *window,
-                              guint32     deviceid,
-                              gdouble         *x,
-                              gdouble         *y,
-                              gdouble         *pressure,
-                              gdouble         *xtilt,
-                              gdouble         *ytilt,
-                              GdkModifierType *mask)
-{
-  GdkDevicePrivate *gdkdev;
-
-  gdkdev = gdk_input_find_device (deviceid);
-  g_return_if_fail (gdkdev != NULL);
-
-  if (gdkdev == gdk_input_core_pointer)
-    gdk_input_common_get_pointer (window, GDK_CORE_POINTER, x, y,
-                                 pressure, xtilt, ytilt, mask);
-  else
-    gdk_input_common_get_pointer (window, deviceid, x, y,
-                                 pressure, xtilt, ytilt, mask);
-}
-
-static GdkTimeCoord *
-gdk_input_gxi_motion_events (GdkWindow *window,
-                            guint32 deviceid,
-                            guint32 start,
-                            guint32 stop,
-                            gint *nevents_return)
-{
-  GdkDevicePrivate *gdkdev;
-
-  gdkdev = gdk_input_find_device (deviceid);
-  g_return_val_if_fail (gdkdev != NULL, NULL);
-  
-
-  if (gdkdev == gdk_input_core_pointer)
-    return gdk_input_motion_events (window, GDK_CORE_POINTER, start, stop,
-                                   nevents_return);
-  else
-    return gdk_input_common_motion_events (window, deviceid, start, stop,
-                                          nevents_return);
-  
-}
-
-static gint 
-gdk_input_gxi_grab_pointer (GdkWindow *     window,
-                           gint            owner_events,
-                           GdkEventMask    event_mask,
-                           GdkWindow *     confine_to,
-                           guint32         time)
-{
-  GList *tmp_list;
-  GdkInputWindow *input_window;
-  GdkDevicePrivate *gdkdev;
-
-  tmp_list = gdk_input_windows;
-  while (tmp_list)
-    {
-      input_window = (GdkInputWindow *)tmp_list->data;
-
-      if (input_window->window == window)
-       input_window->grabbed = TRUE;
-      else if (input_window->grabbed)
-       input_window->grabbed = FALSE;
-
-      tmp_list = tmp_list->next;
-    }
-
-  tmp_list = gdk_input_devices;
-  while (tmp_list)
-    {
-      gdkdev = (GdkDevicePrivate *)tmp_list->data;
-      if (gdkdev->info.deviceid != GDK_CORE_POINTER && 
-         gdkdev->xdevice &&
-         (gdkdev->button_state != 0))
-       gdkdev->button_state = 0;
-      
-      tmp_list = tmp_list->next;
-    }
-
-  return Success;
-}
-
-static void 
-gdk_input_gxi_ungrab_pointer (guint32 time)
-{
-  GdkInputWindow *input_window;
-  GList *tmp_list;
-
-  tmp_list = gdk_input_windows;
-  while (tmp_list)
-    {
-      input_window = (GdkInputWindow *)tmp_list->data;
-      if (input_window->grabbed)
-       input_window->grabbed = FALSE;
-      tmp_list = tmp_list->next;
-    }
-}
-
-#endif /* XINPUT_GXI */
diff --git a/gdk/gdkinputnone.h b/gdk/gdkinputnone.h
deleted file mode 100644 (file)
index 7695726..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#ifdef XINPUT_NONE
-
-static void gdk_input_none_get_pointer (GdkWindow       *window,
-                                       guint32   deviceid,
-                                       gdouble         *x,
-                                       gdouble         *y,
-                                       gdouble         *pressure,
-                                       gdouble         *xtilt,
-                                       gdouble         *ytilt,
-                                       GdkModifierType *mask);
-
-void
-gdk_input_init (void)
-{
-  gdk_input_vtable.set_mode           = NULL;
-  gdk_input_vtable.set_axes           = NULL;
-  gdk_input_vtable.set_key            = NULL;
-  gdk_input_vtable.motion_events      = NULL;
-  gdk_input_vtable.get_pointer        = gdk_input_none_get_pointer;
-  gdk_input_vtable.grab_pointer       = NULL;
-  gdk_input_vtable.ungrab_pointer     = NULL;
-  gdk_input_vtable.configure_event    = NULL;
-  gdk_input_vtable.enter_event        = NULL;
-  gdk_input_vtable.other_event        = NULL;
-  gdk_input_vtable.window_none_event  = NULL;
-  gdk_input_vtable.enable_window      = NULL;
-  gdk_input_vtable.disable_window     = NULL;
-
-  gdk_input_devices = g_list_append (NULL, (GdkDeviceInfo *) &gdk_input_core_info);
-
-  gdk_input_ignore_core = FALSE;
-}
-
-static void
-gdk_input_none_get_pointer (GdkWindow       *window,
-                           guint32          deviceid,
-                           gdouble         *x,
-                           gdouble         *y,
-                           gdouble         *pressure,
-                           gdouble         *xtilt,
-                           gdouble         *ytilt,
-                           GdkModifierType *mask)
-{
-  gint x_int, y_int;
-
-  gdk_window_get_pointer (window, &x_int, &y_int, mask);
-
-  if (x) *x = x_int;
-  if (y) *y = y_int;
-  if (pressure) *pressure = 0.5;
-  if (xtilt) *xtilt = 0;
-  if (ytilt) *ytilt = 0;
-}
-
-#endif /* XINPUT_NONE */
diff --git a/gdk/gdkinputprivate.h b/gdk/gdkinputprivate.h
deleted file mode 100644 (file)
index 0f41c46..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#ifndef __GDK_INPUTPRIVATE_H__
-#define __GDK_INPUTPRIVATE_H__
-
-#ifndef XINPUT_NONE
-#include <X11/extensions/XInput.h>
-#endif
-
-typedef struct _GdkAxisInfo    GdkAxisInfo;
-typedef struct _GdkInputVTable GdkInputVTable;
-typedef struct _GdkDevicePrivate GdkDevicePrivate;
-typedef struct _GdkInputWindow GdkInputWindow;
-
-struct _GdkInputVTable {
-  gint (*set_mode) (guint32 deviceid, GdkInputMode mode);
-  void (*set_axes) (guint32 deviceid, GdkAxisUse *axes);
-  void (*set_key)  (guint32 deviceid,
-                   guint   index,
-                   guint   keyval,
-                   GdkModifierType modifiers);
-       
-  GdkTimeCoord* (*motion_events) (GdkWindow *window,
-                                 guint32 deviceid,
-                                 guint32 start,
-                                 guint32 stop,
-                                 gint *nevents_return);
-  void (*get_pointer)   (GdkWindow       *window,
-                        guint32          deviceid,
-                        gdouble         *x,
-                        gdouble         *y,
-                        gdouble         *pressure,
-                        gdouble         *xtilt,
-                        gdouble         *ytilt,
-                        GdkModifierType *mask);
-  gint (*grab_pointer) (GdkWindow *     window,
-                       gint            owner_events,
-                       GdkEventMask    event_mask,
-                       GdkWindow *     confine_to,
-                       guint32         time);
-  void (*ungrab_pointer) (guint32 time);
-
-  void (*configure_event) (XConfigureEvent *xevent, GdkWindow *window);
-  void (*enter_event) (XCrossingEvent *xevent, GdkWindow *window);
-  gint (*other_event) (GdkEvent *event, XEvent *xevent, GdkWindow *window);
-  /* Handle an unidentified event. Returns TRUE if handled, FALSE
-     otherwise */
-  gint (*window_none_event) (GdkEvent *event, XEvent *xevent);
-  gint (*enable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
-  gint (*disable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
-};
-
-/* information about a device axis */
-struct _GdkAxisInfo
-{
-  /* reported x resolution */
-  gint xresolution;
-
-  /* reported x minimum/maximum values */
-  gint xmin_value, xmax_value;
-
-  /* calibrated resolution (for aspect ration) - only relative values
-     between axes used */
-  gint resolution;
-  
-  /* calibrated minimum/maximum values */
-  gint min_value, max_value;
-};
-
-#define GDK_INPUT_NUM_EVENTC 6
-
-struct _GdkDevicePrivate {
-  GdkDeviceInfo  info;
-
-#ifndef XINPUT_NONE
-  /* information about the axes */
-  GdkAxisInfo *axes;
-
-  /* reverse lookup on axis use type */
-  gint axis_for_use[GDK_AXIS_LAST];
-  
-  /* Information about XInput device */
-  XDevice       *xdevice;
-
-  /* minimum key code for device */
-  gint min_keycode;           
-
-  int buttonpress_type, buttonrelease_type, keypress_type,
-      keyrelease_type, motionnotify_type, proximityin_type, 
-      proximityout_type, changenotify_type;
-
-  /* true if we need to select a different set of events, but
-     can't because this is the core pointer */
-  gint needs_update;
-
-  /* Mask of buttons (used for button grabs) */
-  gint button_state;
-
-  /* true if we've claimed the device as active. (used only for XINPUT_GXI) */
-  gint claimed;
-#endif /* !XINPUT_NONE */
-};
-
-struct _GdkInputWindow
-{
-  /* gdk window */
-  GdkWindow *window;
-
-  /* Extension mode (GDK_EXTENSION_EVENTS_ALL/CURSOR) */
-  GdkExtensionMode mode;
-
-  /* position relative to root window */
-  gint16 root_x;
-  gint16 root_y;
-
-  /* rectangles relative to window of windows obscuring this one */
-  GdkRectangle *obscuring;
-  gint num_obscuring;
-
-  /* Is there a pointer grab for this window ? */
-  gint grabbed;
-};
-
-/* Global data */
-
-extern GdkInputVTable gdk_input_vtable;
-/* information about network port and host for gxid daemon */
-extern gchar           *gdk_input_gxid_host;
-extern gint             gdk_input_gxid_port;
-extern gint             gdk_input_ignore_core;
-
-/* Function declarations */
-
-void gdk_input_window_destroy (GdkWindow *window);
-void gdk_input_init           (void);
-void gdk_input_exit           (void);
-
-#endif /* __GDK_INPUTPRIVATE_H__ */
diff --git a/gdk/gdkinputxfree.h b/gdk/gdkinputxfree.h
deleted file mode 100644 (file)
index d4020ae..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#ifdef XINPUT_XFREE
-
-/* forward declarations */
-
-static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
-static void gdk_input_check_proximity (void);
-static void gdk_input_xfree_configure_event (XConfigureEvent *xevent, 
-                                            GdkWindow *window);
-static void gdk_input_xfree_enter_event (XCrossingEvent *xevent, 
-                                      GdkWindow *window);
-static gint gdk_input_xfree_other_event (GdkEvent *event, 
-                                        XEvent *xevent, 
-                                        GdkWindow *window);
-static gint gdk_input_xfree_enable_window(GdkWindow *window, 
-                                         GdkDevicePrivate *gdkdev);
-static gint gdk_input_xfree_disable_window(GdkWindow *window,
-                                          GdkDevicePrivate *gdkdev);
-static gint gdk_input_xfree_grab_pointer (GdkWindow *     window,
-                                       gint            owner_events,
-                                       GdkEventMask    event_mask,
-                                       GdkWindow *     confine_to,
-                                       guint32         time);
-static void gdk_input_xfree_ungrab_pointer (guint32 time);
-
-void 
-gdk_input_init(void)
-{
-  gdk_input_vtable.set_mode           = gdk_input_xfree_set_mode;
-  gdk_input_vtable.set_axes           = gdk_input_common_set_axes;
-  gdk_input_vtable.set_key            = gdk_input_common_set_key;
-  gdk_input_vtable.motion_events      = gdk_input_common_motion_events;
-  gdk_input_vtable.get_pointer       = gdk_input_common_get_pointer;
-  gdk_input_vtable.grab_pointer              = gdk_input_xfree_grab_pointer;
-  gdk_input_vtable.ungrab_pointer     = gdk_input_xfree_ungrab_pointer;
-  gdk_input_vtable.configure_event    = gdk_input_xfree_configure_event;
-  gdk_input_vtable.enter_event        = gdk_input_xfree_enter_event;
-  gdk_input_vtable.other_event        = gdk_input_xfree_other_event;
-  gdk_input_vtable.window_none_event  = NULL;
-  gdk_input_vtable.enable_window      = gdk_input_xfree_enable_window;
-  gdk_input_vtable.disable_window     = gdk_input_xfree_disable_window;
-
-  gdk_input_ignore_core = FALSE;
-  gdk_input_common_init(FALSE);
-}
-
-static gint
-gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode)
-{
-  GList *tmp_list;
-  GdkDevicePrivate *gdkdev;
-  GdkInputMode old_mode;
-  GdkInputWindow *input_window;
-
-  gdkdev = gdk_input_find_device(deviceid);
-  g_return_val_if_fail (gdkdev != NULL,FALSE);
-  old_mode = gdkdev->info.mode;
-
-  if (gdkdev->info.mode == mode)
-    return TRUE;
-
-  gdkdev->info.mode = mode;
-
-  if (mode == GDK_MODE_WINDOW)
-    {
-      gdkdev->info.has_cursor = FALSE;
-      for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
-       {
-         input_window = (GdkInputWindow *)tmp_list->data;
-         if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
-           gdk_input_enable_window (input_window->window, gdkdev);
-         else
-           if (old_mode != GDK_MODE_DISABLED)
-             gdk_input_disable_window (input_window->window, gdkdev);
-       }
-    }
-  else if (mode == GDK_MODE_SCREEN)
-    {
-      gdkdev->info.has_cursor = TRUE;
-      for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
-       gdk_input_enable_window (((GdkInputWindow *)tmp_list->data)->window,
-                                gdkdev);
-    }
-  else  /* mode == GDK_MODE_DISABLED */
-    {
-      for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
-       {
-         input_window = (GdkInputWindow *)tmp_list->data;
-         if (old_mode != GDK_MODE_WINDOW ||
-             input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
-           gdk_input_disable_window (input_window->window, gdkdev);
-       }
-    }
-
-  return TRUE;
-  
-}
-
-static void
-gdk_input_check_proximity (void)
-{
-  gint new_proximity = 0;
-  GList *tmp_list = gdk_input_devices;
-
-  while (tmp_list && !new_proximity) 
-    {
-      GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
-
-      if (gdkdev->info.mode != GDK_MODE_DISABLED 
-         && gdkdev->info.deviceid != GDK_CORE_POINTER
-         && gdkdev->xdevice)
-       {
-         XDeviceState *state = XQueryDeviceState(GDK_DISPLAY(),
-                                                 gdkdev->xdevice);
-         XInputClass *xic;
-         int i;
-         
-         xic = state->data;
-         for (i=0; i<state->num_classes; i++)
-           {
-             if (xic->class == ValuatorClass)
-               {
-                 XValuatorState *xvs = (XValuatorState *)xic;
-                 if ((xvs->mode & ProximityState) == InProximity)
-                   {
-                     new_proximity = TRUE;
-                   }
-                 break;
-               }
-             xic = (XInputClass *)((char *)xic + xic->length);
-           }
-       }
-      tmp_list = tmp_list->next;
-    }
-
-  gdk_input_ignore_core = new_proximity;
-}
-
-static void
-gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window)
-{
-  GdkInputWindow *input_window;
-  gint root_x, root_y;
-
-  input_window = gdk_input_window_find(window);
-  g_return_if_fail (window != NULL);
-
-  gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
-                                &root_x, 
-                                &root_y, NULL, NULL);
-
-  input_window->root_x = root_x;
-  input_window->root_y = root_y;
-}
-
-static void 
-gdk_input_xfree_enter_event (XCrossingEvent *xevent, 
-                            GdkWindow      *window)
-{
-  GdkInputWindow *input_window;
-  gint root_x, root_y;
-
-  input_window = gdk_input_window_find(window);
-  g_return_if_fail (window != NULL);
-
-  gdk_input_check_proximity();
-
-  gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
-                                &root_x, 
-                                &root_y, NULL, NULL);
-
-  input_window->root_x = root_x;
-  input_window->root_y = root_y;
-}
-
-static gint 
-gdk_input_xfree_other_event (GdkEvent *event, 
-                            XEvent *xevent, 
-                            GdkWindow *window)
-{
-  GdkInputWindow *input_window;
-
-  GdkDevicePrivate *gdkdev;
-  gint return_val;
-
-  input_window = gdk_input_window_find(window);
-  g_return_val_if_fail (window != NULL, -1);
-
-  /* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
-     but it's potentially faster than scanning through the types of
-     every device. If we were deceived, then it won't match any of
-     the types for the device anyways */
-  gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
-
-  if (!gdkdev) {
-    return -1;                 /* we don't handle it - not an XInput event */
-  }
-
-  /* FIXME: It would be nice if we could just get rid of the events 
-     entirely, instead of having to ignore them */
-  if (gdkdev->info.mode == GDK_MODE_DISABLED ||
-      (gdkdev->info.mode == GDK_MODE_WINDOW 
-       && input_window->mode == GDK_EXTENSION_EVENTS_CURSOR))
-    return FALSE;
-  
-  if (!gdk_input_ignore_core)
-    gdk_input_check_proximity();
-
-  return_val = gdk_input_common_other_event (event, xevent, 
-                                            input_window, gdkdev);
-
-  if (return_val > 0 && event->type == GDK_PROXIMITY_OUT &&
-      gdk_input_ignore_core)
-    gdk_input_check_proximity();
-
-  return return_val;
-}
-
-static gint
-gdk_input_xfree_enable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
-{
-  /* FIXME: watchout, gdkdev might be core pointer, never opened */
-  gdk_input_common_select_events (window, gdkdev);
-  return TRUE;
-}
-
-static gint
-gdk_input_xfree_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
-{
-  gdk_input_common_select_events (window, gdkdev);
-  return TRUE;
-}
-
-static gint 
-gdk_input_xfree_grab_pointer (GdkWindow *     window,
-                             gint            owner_events,
-                             GdkEventMask    event_mask,
-                             GdkWindow *     confine_to,
-                             guint32         time)
-{
-  GdkInputWindow *input_window, *new_window;
-  gboolean need_ungrab;
-  GdkDevicePrivate *gdkdev;
-  GList *tmp_list;
-  XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
-  gint num_classes;
-  gint result;
-
-  tmp_list = gdk_input_windows;
-  new_window = NULL;
-  need_ungrab = FALSE;
-
-  while (tmp_list)
-    {
-      input_window = (GdkInputWindow *)tmp_list->data;
-
-      if (input_window->window == window)
-       new_window = input_window;
-      else if (input_window->grabbed)
-       {
-         input_window->grabbed = FALSE;
-         need_ungrab = TRUE;
-       }
-
-      tmp_list = tmp_list->next;
-    }
-
-  if (new_window)
-    {
-      new_window->grabbed = TRUE;
-      
-      tmp_list = gdk_input_devices;
-      while (tmp_list)
-       {
-         gdkdev = (GdkDevicePrivate *)tmp_list->data;
-         if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
-             gdkdev->xdevice)
-           {
-             gdk_input_common_find_events (window, gdkdev,
-                                           event_mask,
-                                           event_classes, &num_classes);
-             
-             result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
-                                   GDK_WINDOW_XWINDOW (window),
-                                   owner_events, num_classes, event_classes,
-                                   GrabModeAsync, GrabModeAsync, time);
-             
-             /* FIXME: if failure occurs on something other than the first
-                device, things will be badly inconsistent */
-             if (result != Success)
-               return result;
-           }
-         tmp_list = tmp_list->next;
-       }
-    }
-  else
-    { 
-      tmp_list = gdk_input_devices;
-      while (tmp_list)
-       {
-         gdkdev = (GdkDevicePrivate *)tmp_list->data;
-         if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice &&
-             ((gdkdev->button_state != 0) || need_ungrab))
-           {
-             XUngrabDevice( gdk_display, gdkdev->xdevice, time);
-             gdkdev->button_state = 0;
-           }
-         
-         tmp_list = tmp_list->next;
-       }
-    }
-
-  return Success;
-      
-}
-
-static void 
-gdk_input_xfree_ungrab_pointer (guint32 time)
-{
-  GdkInputWindow *input_window;
-  GdkDevicePrivate *gdkdev;
-  GList *tmp_list;
-
-  tmp_list = gdk_input_windows;
-  while (tmp_list)
-    {
-      input_window = (GdkInputWindow *)tmp_list->data;
-      if (input_window->grabbed)
-       break;
-      tmp_list = tmp_list->next;
-    }
-
-  if (tmp_list)                        /* we found a grabbed window */
-    {
-      input_window->grabbed = FALSE;
-
-      tmp_list = gdk_input_devices;
-      while (tmp_list)
-       {
-         gdkdev = (GdkDevicePrivate *)tmp_list->data;
-         if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice)
-           XUngrabDevice( gdk_display, gdkdev->xdevice, time);
-
-         tmp_list = tmp_list->next;
-       }
-    }
-}
-
-#endif /* XINPUT_XFREE */
diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c
deleted file mode 100644 (file)
index 8ee69db..0000000
+++ /dev/null
@@ -1,826 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-/* Needed for SEEK_END in SunOS */
-#include <unistd.h>
-#include <X11/Xlib.h>
-
-#include "gdkpixmap.h"
-#include "gdkprivate.h"
-#include "gdkx.h"
-
-typedef struct
-{
-  gchar *color_string;
-  GdkColor color;
-  gint transparent;
-} _GdkPixmapColor;
-
-typedef struct
-{
-  guint ncolors;
-  GdkColormap *colormap;
-  gulong pixels[1];
-} _GdkPixmapInfo;
-
-GdkPixmap*
-gdk_pixmap_new (GdkWindow *window,
-               gint       width,
-               gint       height,
-               gint       depth)
-{
-  GdkPixmap *pixmap;
-  GdkDrawablePrivate *private;
-
-  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
-  g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
-  g_return_val_if_fail ((width != 0) && (height != 0), NULL);
-
-  if (!window)
-    window = (GdkWindow*) &gdk_root_parent;
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return NULL;
-
-  if (depth == -1)
-    depth = gdk_drawable_get_visual (window)->depth;
-
-  private = g_new0 (GdkDrawablePrivate, 1);
-  pixmap = (GdkPixmap*) private;
-
-  private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
-  private->window_type = GDK_DRAWABLE_PIXMAP;
-  private->xwindow = XCreatePixmap (private->xdisplay,
-                                   GDK_DRAWABLE_XID (window),
-                                   width, height, depth);
-  private->colormap = NULL;
-  private->width = width;
-  private->height = height;
-  private->ref_count = 1;
-  private->destroyed = 0;
-
-  gdk_xid_table_insert (&private->xwindow, pixmap);
-
-  return pixmap;
-}
-
-GdkPixmap *
-gdk_bitmap_create_from_data (GdkWindow   *window,
-                            const gchar *data,
-                            gint         width,
-                            gint         height)
-{
-  GdkPixmap *pixmap;
-  GdkDrawablePrivate *private;
-
-  g_return_val_if_fail (data != NULL, NULL);
-  g_return_val_if_fail ((width != 0) && (height != 0), NULL);
-  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
-
-  if (!window)
-    window = (GdkWindow*) &gdk_root_parent;
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return NULL;
-
-  private = g_new0 (GdkDrawablePrivate, 1);
-  pixmap = (GdkPixmap*) private;
-
-  private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
-  private->window_type = GDK_DRAWABLE_PIXMAP;
-  private->width = width;
-  private->height = height;
-  private->ref_count = 1;
-  private->destroyed = FALSE;
-
-  private->xwindow = XCreateBitmapFromData (private->xdisplay,
-                                           GDK_DRAWABLE_XID (window),
-                                           (char *)data, width, height);
-
-  gdk_xid_table_insert (&private->xwindow, pixmap);
-
-  return pixmap;
-}
-
-GdkPixmap*
-gdk_pixmap_create_from_data (GdkWindow   *window,
-                            const gchar *data,
-                            gint         width,
-                            gint         height,
-                            gint         depth,
-                            GdkColor    *fg,
-                            GdkColor    *bg)
-{
-  GdkPixmap *pixmap;
-  GdkDrawablePrivate *private;
-
-  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
-  g_return_val_if_fail (data != NULL, NULL);
-  g_return_val_if_fail (fg != NULL, NULL);
-  g_return_val_if_fail (bg != NULL, NULL);
-  g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
-  g_return_val_if_fail ((width != 0) && (height != 0), NULL);
-
-  if (!window)
-    window = (GdkWindow*) &gdk_root_parent;
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return NULL;
-
-  if (depth == -1)
-    depth = gdk_drawable_get_visual (window)->depth;
-
-  private = g_new0 (GdkDrawablePrivate, 1);
-  pixmap = (GdkPixmap*) private;
-
-  private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
-  private->window_type = GDK_DRAWABLE_PIXMAP;
-  private->width = width;
-  private->height = height;
-  private->ref_count = 1;
-  private->destroyed = FALSE;
-
-  private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay,
-                                                 GDK_DRAWABLE_XID (window),
-                                                 (char *)data, width, height,
-                                                 fg->pixel, bg->pixel, depth);
-
-  gdk_xid_table_insert (&private->xwindow, pixmap);
-
-  return pixmap;
-}
-
-static gint
-gdk_pixmap_seek_string (FILE  *infile,
-                        const gchar *str,
-                        gint   skip_comments)
-{
-  char instr[1024];
-
-  while (!feof (infile))
-    {
-      fscanf (infile, "%1023s", instr);
-      if (skip_comments == TRUE && strcmp (instr, "/*") == 0)
-        {
-          fscanf (infile, "%1023s", instr);
-          while (!feof (infile) && strcmp (instr, "*/") != 0)
-            fscanf (infile, "%1023s", instr);
-          fscanf(infile, "%1023s", instr);
-        }
-      if (strcmp (instr, str)==0)
-        return TRUE;
-    }
-
-  return FALSE;
-}
-
-static gint
-gdk_pixmap_seek_char (FILE  *infile,
-                      gchar  c)
-{
-  gint b, oldb;
-
-  while ((b = getc(infile)) != EOF)
-    {
-      if (c != b && b == '/')
-       {
-         b = getc (infile);
-         if (b == EOF)
-           return FALSE;
-         else if (b == '*')    /* we have a comment */
-           {
-             b = -1;
-             do
-               {
-                 oldb = b;
-                 b = getc (infile);
-                 if (b == EOF)
-                   return FALSE;
-               }
-             while (!(oldb == '*' && b == '/'));
-           }
-        }
-      else if (c == b)
-       return TRUE;
-    }
-  return FALSE;
-}
-
-static gint
-gdk_pixmap_read_string (FILE  *infile,
-                        gchar **buffer,
-                       guint *buffer_size)
-{
-  gint c;
-  guint cnt = 0, bufsiz, ret = FALSE;
-  gchar *buf;
-
-  buf = *buffer;
-  bufsiz = *buffer_size;
-  if (buf == NULL)
-    {
-      bufsiz = 10 * sizeof (gchar);
-      buf = g_new(gchar, bufsiz);
-    }
-
-  do
-    c = getc (infile);
-  while (c != EOF && c != '"');
-
-  if (c != '"')
-    goto out;
-
-  while ((c = getc(infile)) != EOF)
-    {
-      if (cnt == bufsiz)
-       {
-         guint new_size = bufsiz * 2;
-         if (new_size > bufsiz)
-           bufsiz = new_size;
-         else
-           goto out;
-         
-         buf = (gchar *) g_realloc (buf, bufsiz);
-         buf[bufsiz-1] = '\0';
-       }
-
-      if (c != '"')
-        buf[cnt++] = c;
-      else
-        {
-          buf[cnt] = 0;
-         ret = TRUE;
-         break;
-        }
-    }
-
- out:
-  buf[bufsiz-1] = '\0';                /* ensure null termination for errors */
-  *buffer = buf;
-  *buffer_size = bufsiz;
-  return ret;
-}
-
-static gchar*
-gdk_pixmap_skip_whitespaces (gchar *buffer)
-{
-  gint32 index = 0;
-
-  while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09))
-    index++;
-
-  return &buffer[index];
-}
-
-static gchar*
-gdk_pixmap_skip_string (gchar *buffer)
-{
-  gint32 index = 0;
-
-  while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09)
-    index++;
-
-  return &buffer[index];
-}
-
-/* Xlib crashed ince at a color name lengths around 125 */
-#define MAX_COLOR_LEN 120
-
-static gchar*
-gdk_pixmap_extract_color (gchar *buffer)
-{
-  gint counter, numnames;
-  gchar *ptr = NULL, ch, temp[128];
-  gchar color[MAX_COLOR_LEN], *retcol;
-  gint space;
-
-  counter = 0;
-  while (ptr == NULL)
-    {
-      if (buffer[counter] == 'c')
-        {
-          ch = buffer[counter + 1];
-          if (ch == 0x20 || ch == 0x09)
-            ptr = &buffer[counter + 1];
-        }
-      else if (buffer[counter] == 0)
-        return NULL;
-
-      counter++;
-    }
-
-  ptr = gdk_pixmap_skip_whitespaces (ptr);
-
-  if (ptr[0] == 0)
-    return NULL;
-  else if (ptr[0] == '#')
-    {
-      counter = 1;
-      while (ptr[counter] != 0 && 
-             ((ptr[counter] >= '0' && ptr[counter] <= '9') ||
-              (ptr[counter] >= 'a' && ptr[counter] <= 'f') ||
-              (ptr[counter] >= 'A' && ptr[counter] <= 'F')))
-        counter++;
-
-      retcol = g_new (gchar, counter+1);
-      strncpy (retcol, ptr, counter);
-
-      retcol[counter] = 0;
-      
-      return retcol;
-    }
-
-  color[0] = 0;
-  numnames = 0;
-
-  space = MAX_COLOR_LEN - 1;
-  while (space > 0)
-    {
-      sscanf (ptr, "%127s", temp);
-
-      if (((gint)ptr[0] == 0) ||
-         (strcmp ("s", temp) == 0) || (strcmp ("m", temp) == 0) ||
-          (strcmp ("g", temp) == 0) || (strcmp ("g4", temp) == 0))
-       {
-         break;
-       }
-      else
-        {
-          if (numnames > 0)
-           {
-             space -= 1;
-             strcat (color, " ");
-           }
-         strncat (color, temp, space);
-         space -= MIN (space, strlen (temp));
-          ptr = gdk_pixmap_skip_string (ptr);
-          ptr = gdk_pixmap_skip_whitespaces (ptr);
-          numnames++;
-        }
-    }
-
-  retcol = g_strdup (color);
-  return retcol;
-}
-
-
-enum buffer_op
-{
-  op_header,
-  op_cmap,
-  op_body
-};
-  
-
-static void 
-gdk_xpm_destroy_notify (gpointer data)
-{
-  _GdkPixmapInfo *info = (_GdkPixmapInfo *)data;
-  GdkColor color;
-  int i;
-
-  for (i=0; i<info->ncolors; i++)
-    {
-      color.pixel = info->pixels[i];
-      gdk_colormap_free_colors (info->colormap, &color, 1);
-    }
-
-  gdk_colormap_unref (info->colormap);
-  g_free (info);
-}
-  
-static GdkPixmap *
-_gdk_pixmap_create_from_xpm (GdkWindow  *window,
-                            GdkColormap *colormap,
-                            GdkBitmap **mask,
-                            GdkColor   *transparent_color,
-                            gchar *   (*get_buf) (enum buffer_op op,
-                                                  gpointer       handle),
-                            gpointer    handle)
-{
-  GdkPixmap *pixmap = NULL;
-  GdkImage *image = NULL;
-  GdkVisual *visual;
-  GdkGC *gc = NULL;
-  GdkColor tmp_color;
-  gint width, height, num_cols, cpp, n, ns, cnt, xcnt, ycnt, wbytes;
-  gchar *buffer, pixel_str[32];
-  gchar *name_buf;
-  _GdkPixmapColor *color = NULL, *fallbackcolor = NULL;
-  _GdkPixmapColor *colors = NULL;
-  gulong index;
-  GHashTable *color_hash = NULL;
-  _GdkPixmapInfo *color_info = NULL;
-  
-  if ((window == NULL) && (colormap == NULL))
-    g_warning ("Creating pixmap from xpm with NULL window and colormap");
-  
-  if (window == NULL)
-    window = (GdkWindow *)&gdk_root_parent;
-  
-  if (colormap == NULL)
-    {
-      colormap = gdk_drawable_get_colormap (window);
-      visual = gdk_drawable_get_visual (window);
-    }
-  else
-    visual = ((GdkColormapPrivate *)colormap)->visual;
-  
-  buffer = (*get_buf) (op_header, handle);
-  if (buffer == NULL)
-    return NULL;
-  
-  sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
-  if (cpp >= 32)
-    {
-      g_warning ("Pixmap has more than 31 characters per color\n");
-      return NULL;
-    }
-  
-  color_hash = g_hash_table_new (g_str_hash, g_str_equal);
-  
-  if (transparent_color == NULL)
-    {
-      gdk_color_white (colormap, &tmp_color);
-      transparent_color = &tmp_color;
-    }
-
-  /* For pseudo-color and grayscale visuals, we have to remember
-   * the colors we allocated, so we can free them later.
-   */
-  if ((visual->type == GDK_VISUAL_PSEUDO_COLOR) ||
-      (visual->type == GDK_VISUAL_GRAYSCALE))
-    {
-      color_info = g_malloc (sizeof (_GdkPixmapInfo) + 
-                            sizeof(gulong) * (num_cols - 1));
-      color_info->ncolors = num_cols;
-      color_info->colormap = colormap;
-      gdk_colormap_ref (colormap);
-    }
-
-  name_buf = g_new (gchar, num_cols * (cpp+1));
-  colors = g_new (_GdkPixmapColor, num_cols);
-
-  for (cnt = 0; cnt < num_cols; cnt++)
-    {
-      gchar *color_name;
-      
-      buffer = (*get_buf) (op_cmap, handle);
-      if (buffer == NULL)
-       goto error;
-      
-      color = &colors[cnt];
-      color->color_string = &name_buf [cnt * (cpp + 1)];
-      strncpy (color->color_string, buffer, cpp);
-      color->color_string[cpp] = 0;
-      buffer += strlen (color->color_string);
-      color->transparent = FALSE;
-      
-      color_name = gdk_pixmap_extract_color (buffer);
-      
-      if (color_name == NULL || g_strcasecmp (color_name, "None") == 0 ||
-         gdk_color_parse (color_name, &color->color) == FALSE)
-       {
-         color->color = *transparent_color;
-         color->transparent = TRUE;
-       }
-      
-      g_free (color_name);
-      
-      /* FIXME: The remaining slowness appears to happen in this
-         function. */
-      gdk_color_alloc (colormap, &color->color);
-
-      if (color_info)
-       color_info->pixels[cnt] = color->color.pixel;
-      
-      g_hash_table_insert (color_hash, color->color_string, color);
-      if (cnt == 0)
-       fallbackcolor = color;
-    }
-  
-  index = 0;
-  image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
-  
-  if (mask)
-    {
-      /* The pixmap mask is just a bits pattern.
-       * Color 0 is used for background and 1 for foreground.
-       * We don't care about the colormap, we just need 0 and 1.
-       */
-      GdkColor mask_pattern;
-      
-      *mask = gdk_pixmap_new (window, width, height, 1);
-      gc = gdk_gc_new (*mask);
-      
-      mask_pattern.pixel = 0;
-      gdk_gc_set_foreground (gc, &mask_pattern);
-      gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
-      
-      mask_pattern.pixel = 1;
-      gdk_gc_set_foreground (gc, &mask_pattern);
-    }
-  
-  wbytes = width * cpp;
-  for (ycnt = 0; ycnt < height; ycnt++)
-    {
-      buffer = (*get_buf) (op_body, handle);
-      
-      /* FIXME: this slows things down a little - it could be
-       * integrated into the strncpy below, perhaps. OTOH, strlen
-       * is fast.
-       */
-      if ((buffer == NULL) || strlen (buffer) < wbytes)
-       continue;
-      
-      for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++)
-       {
-         strncpy (pixel_str, &buffer[n], cpp);
-         pixel_str[cpp] = 0;
-         ns = 0;
-         
-         color = g_hash_table_lookup (color_hash, pixel_str);
-         
-         if (!color) /* screwed up XPM file */
-           color = fallbackcolor;
-         
-         gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
-         
-         if (mask && color->transparent)
-           {
-             if (cnt < xcnt)
-               gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
-             cnt = xcnt + 1;
-           }
-       }
-      
-      if (mask && (cnt < xcnt))
-       gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
-    }
-  
- error:
-  
-  if (mask)
-    gdk_gc_destroy (gc);
-  
-  if (image != NULL)
-    {
-      pixmap = gdk_pixmap_new (window, width, height, visual->depth);
-
-      if (color_info)
-       gdk_drawable_set_data (pixmap, "gdk-xpm", color_info, 
-                              gdk_xpm_destroy_notify);
-      
-      gc = gdk_gc_new (pixmap);
-      gdk_gc_set_foreground (gc, transparent_color);
-      gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
-      gdk_gc_destroy (gc);
-      gdk_image_destroy (image);
-    }
-  else if (color_info)
-    gdk_xpm_destroy_notify (color_info);
-  
-  if (color_hash != NULL)
-    g_hash_table_destroy (color_hash);
-
-  if (colors != NULL)
-    g_free (colors);
-
-  if (name_buf != NULL)
-    g_free (name_buf);
-
-  return pixmap;
-}
-
-
-struct file_handle
-{
-  FILE *infile;
-  gchar *buffer;
-  guint buffer_size;
-};
-
-
-static gchar *
-file_buffer (enum buffer_op op, gpointer handle)
-{
-  struct file_handle *h = handle;
-
-  switch (op)
-    {
-    case op_header:
-      if (gdk_pixmap_seek_string (h->infile, "XPM", FALSE) != TRUE)
-       break;
-
-      if (gdk_pixmap_seek_char (h->infile,'{') != TRUE)
-       break;
-      /* Fall through to the next gdk_pixmap_seek_char. */
-
-    case op_cmap:
-      gdk_pixmap_seek_char (h->infile, '"');
-      fseek (h->infile, -1, SEEK_CUR);
-      /* Fall through to the gdk_pixmap_read_string. */
-
-    case op_body:
-      gdk_pixmap_read_string (h->infile, &h->buffer, &h->buffer_size);
-      return h->buffer;
-    }
-  return 0;
-}
-
-
-GdkPixmap*
-gdk_pixmap_colormap_create_from_xpm (GdkWindow   *window,
-                                    GdkColormap *colormap,
-                                    GdkBitmap  **mask,
-                                    GdkColor    *transparent_color,
-                                    const gchar *filename)
-{
-  struct file_handle h;
-  GdkPixmap *pixmap = NULL;
-
-  memset (&h, 0, sizeof (h));
-  h.infile = fopen (filename, "rb");
-  if (h.infile != NULL)
-    {
-      pixmap = _gdk_pixmap_create_from_xpm (window, colormap, mask,
-                                           transparent_color,
-                                           file_buffer, &h);
-      fclose (h.infile);
-      g_free (h.buffer);
-    }
-
-  return pixmap;
-}
-
-GdkPixmap*
-gdk_pixmap_create_from_xpm (GdkWindow  *window,
-                           GdkBitmap **mask,
-                           GdkColor   *transparent_color,
-                           const gchar *filename)
-{
-  return gdk_pixmap_colormap_create_from_xpm (window, NULL, mask,
-                                      transparent_color, filename);
-}
-
-
-struct mem_handle
-{
-  gchar **data;
-  int offset;
-};
-
-
-static gchar *
-mem_buffer (enum buffer_op op, gpointer handle)
-{
-  struct mem_handle *h = handle;
-  switch (op)
-    {
-    case op_header:
-    case op_cmap:
-    case op_body:
-      if (h->data[h->offset])
-       return h->data[h->offset ++];
-    }
-  return 0;
-}
-
-
-GdkPixmap*
-gdk_pixmap_colormap_create_from_xpm_d (GdkWindow  *window,
-                                      GdkColormap *colormap,
-                                      GdkBitmap **mask,
-                                      GdkColor   *transparent_color,
-                                      gchar     **data)
-{
-  struct mem_handle h;
-  GdkPixmap *pixmap = NULL;
-
-  memset (&h, 0, sizeof (h));
-  h.data = data;
-  pixmap = _gdk_pixmap_create_from_xpm (window, colormap, mask,
-                                       transparent_color,
-                                       mem_buffer, &h);
-  return pixmap;
-}
-
-
-GdkPixmap*
-gdk_pixmap_create_from_xpm_d (GdkWindow  *window,
-                             GdkBitmap **mask,
-                             GdkColor   *transparent_color,
-                             gchar     **data)
-{
-  return gdk_pixmap_colormap_create_from_xpm_d (window, NULL, mask,
-                                               transparent_color, data);
-}
-
-GdkPixmap*
-gdk_pixmap_foreign_new (guint32 anid)
-{
-  GdkPixmap *pixmap;
-  GdkDrawablePrivate *private;
-  Pixmap xpixmap;
-  Window root_return;
-  unsigned int x_ret, y_ret, w_ret, h_ret, bw_ret, depth_ret;
-
-  /* check to make sure we were passed something at
-     least a little sane */
-  g_return_val_if_fail((anid != 0), NULL);
-  
-  /* set the pixmap to the passed in value */
-  xpixmap = anid;
-
-  /* get information about the Pixmap to fill in the structure for
-     the gdk window */
-  if (!XGetGeometry(GDK_DISPLAY(),
-                   xpixmap, &root_return,
-                   &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
-      return NULL;
-      
-  /* allocate a new gdk pixmap */
-  private = g_new(GdkDrawablePrivate, 1);
-  pixmap = (GdkPixmap *)private;
-
-  private->xdisplay = GDK_DISPLAY();
-  private->window_type = GDK_DRAWABLE_PIXMAP;
-  private->xwindow = xpixmap;
-  private->colormap = NULL;
-  private->width = w_ret;
-  private->height = h_ret;
-  private->ref_count = 1;
-  private->destroyed = 0;
-  
-  gdk_xid_table_insert(&private->xwindow, pixmap);
-
-  return pixmap;
-}
-
-GdkPixmap*
-gdk_pixmap_ref (GdkPixmap *pixmap)
-{
-  GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap;
-  g_return_val_if_fail (pixmap != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_PIXMAP (private), NULL);
-
-  private->ref_count += 1;
-  return pixmap;
-}
-
-void
-gdk_pixmap_unref (GdkPixmap *pixmap)
-{
-  GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap;
-  g_return_if_fail (pixmap != NULL);
-  g_return_if_fail (GDK_IS_PIXMAP (private));
-  g_return_if_fail (private->ref_count > 0);
-
-  private->ref_count -= 1;
-  if (private->ref_count == 0)
-    {
-      XFreePixmap (private->xdisplay, private->xwindow);
-      gdk_xid_table_remove (private->xwindow);
-      g_dataset_destroy (private);
-      g_free (private);
-    }
-}
-
-GdkBitmap *
-gdk_bitmap_ref (GdkBitmap *bitmap)
-{
-  return (GdkBitmap *)gdk_pixmap_ref ((GdkPixmap *)bitmap);
-}
-
-void
-gdk_bitmap_unref (GdkBitmap *bitmap)
-{
-  gdk_pixmap_unref ((GdkPixmap *)bitmap);
-}
index b7ec3901470c9ba3cd5f8d37c14c85a9f4f7fd7b..833f078c45062e84e5e901ce9ca1671ed1472b4d 100644 (file)
 #ifndef __GDK_PRIVATE_H__
 #define __GDK_PRIVATE_H__
 
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
 #include <gdk/gdktypes.h>
-
-#include <gdk/gdkcursor.h>
 #include <gdk/gdkevents.h>
 #include <gdk/gdkfont.h>
 #include <gdk/gdkgc.h>
@@ -60,20 +54,20 @@ extern "C" {
 typedef struct _GdkDrawablePrivate     GdkDrawablePrivate;
 /* typedef struct _GdkDrawablePrivate     GdkPixmapPrivate; */
 typedef struct _GdkWindowPrivate       GdkWindowPrivate;
+typedef struct _GdkImageClass         GdkImageClass;
 typedef struct _GdkImagePrivate               GdkImagePrivate;
 typedef struct _GdkGCPrivate          GdkGCPrivate;
 typedef struct _GdkColormapPrivate     GdkColormapPrivate;
 typedef struct _GdkColorInfo           GdkColorInfo;
-typedef struct _GdkVisualPrivate       GdkVisualPrivate;
 typedef struct _GdkFontPrivate        GdkFontPrivate;
-typedef struct _GdkCursorPrivate       GdkCursorPrivate;
 typedef struct _GdkEventFilter        GdkEventFilter;
 typedef struct _GdkClientFilter               GdkClientFilter;
-typedef struct _GdkRegionPrivate       GdkRegionPrivate;
 
 struct _GdkDrawablePrivate
 {
   GdkDrawable drawable;
+  GdkDrawableClass *klass;
+  gpointer klass_data;
 
   guint8 window_type;
   guint ref_count;
@@ -81,8 +75,6 @@ struct _GdkDrawablePrivate
   guint16 width;
   guint16 height;
 
-  Window xwindow;
-  Display *xdisplay;
   GdkColormap *colormap;
 
   guint destroyed : 2;
@@ -92,7 +84,6 @@ struct _GdkWindowPrivate
 {
   GdkDrawablePrivate drawable;
   
-  GdkWindow window;
   GdkWindow *parent;
   gint16 x;
   gint16 y;
@@ -103,20 +94,15 @@ struct _GdkWindowPrivate
   gint extension_events;
 
   GList *filters;
-  GdkColormap *colormap;
   GList *children;
 };
 
-struct _GdkImagePrivate
+struct _GdkImageClass 
 {
-  GdkImage image;
-  XImage *ximage;
-  Display *xdisplay;
-  gpointer x_shm_info;
-
-  void (*image_put) (GdkDrawable *window,
+  void (*destroy)   (GdkImage    *image);
+  void (*image_put) (GdkImage   *image,
+                    GdkDrawable *window,
                     GdkGC       *gc,
-                    GdkImage    *image,
                     gint         xsrc,
                     gint         ysrc,
                     gint         xdest,
@@ -125,12 +111,25 @@ struct _GdkImagePrivate
                     gint         height);
 };
 
+struct _GdkImagePrivate
+{
+  GdkImage image;
+
+  guint ref_count;
+  GdkImageClass *klass;
+};
+
+struct _GdkFontPrivate
+{
+  GdkFont font;
+  guint ref_count;
+};
+
 struct _GdkGCPrivate
 {
-  GdkGC gc;
-  GC xgc;
-  Display *xdisplay;
   guint ref_count;
+  GdkGCClass *klass;
+  gpointer klass_data;
 };
 
 typedef enum {
@@ -146,71 +145,11 @@ struct _GdkColorInfo
 struct _GdkColormapPrivate
 {
   GdkColormap colormap;
-  Colormap xcolormap;
-  Display *xdisplay;
   GdkVisual *visual;
-  gint private_val;
 
-  GHashTable *hash;
-  GdkColorInfo *info;
-  time_t last_sync_time;
-  
-  guint ref_count;
-};
-
-struct _GdkVisualPrivate
-{
-  GdkVisual visual;
-  Visual *xvisual;
-};
-
-struct _GdkFontPrivate
-{
-  GdkFont font;
-  /* XFontStruct *xfont; */
-  /* generic pointer point to XFontStruct or XFontSet */
-  gpointer xfont;
-  Display *xdisplay;
   guint ref_count;
-
-  GSList *names;
-};
-
-struct _GdkCursorPrivate
-{
-  GdkCursor cursor;
-  Cursor xcursor;
-  Display *xdisplay;
 };
 
-struct _GdkDndCursorInfo {
-  Cursor         gdk_cursor_dragdefault, gdk_cursor_dragok;
-  GdkWindow     *drag_pm_default, *drag_pm_ok;
-  GdkPoint       default_hotspot, ok_hotspot;
-  GList *xids;
-};
-typedef struct _GdkDndCursorInfo GdkDndCursorInfo;
-
-struct _GdkDndGlobals {
-  GdkAtom           gdk_XdeEnter, gdk_XdeLeave, gdk_XdeRequest;
-  GdkAtom           gdk_XdeDataAvailable, gdk_XdeDataShow, gdk_XdeCancel;
-  GdkAtom           gdk_XdeTypelist;
-
-  GdkDndCursorInfo  *c;
-  GdkWindow    **drag_startwindows;
-  guint                  drag_numwindows;
-  gboolean       drag_really, drag_perhaps, dnd_grabbed;
-  Window         dnd_drag_target;
-  GdkPoint       drag_dropcoords;
-
-  GdkPoint dnd_drag_start, dnd_drag_oldpos;
-  GdkRectangle dnd_drag_dropzone;
-  GdkWindowPrivate *real_sw;
-  Window dnd_drag_curwin;
-  Time last_drop_time; /* An incredible hack, sosumi miguel */
-};
-typedef struct _GdkDndGlobals GdkDndGlobals;
-
 struct _GdkEventFilter {
   GdkFilterFunc function;
   gpointer data;
@@ -222,25 +161,36 @@ struct _GdkClientFilter {
   gpointer      data;
 };
 
-#ifdef USE_XIM
+typedef enum 
+{
+  GDK_ARG_STRING,
+  GDK_ARG_INT,
+  GDK_ARG_BOOL,
+  GDK_ARG_NOBOOL,
+  GDK_ARG_CALLBACK
+} GdkArgType;
+
 
-typedef struct _GdkICPrivate GdkICPrivate;
+typedef struct _GdkArgContext GdkArgContext;
+typedef struct _GdkArgDesc GdkArgDesc;
 
-struct _GdkICPrivate
+typedef void (*GdkArgFunc) (const char *name, const char *arg, gpointer data);
+
+struct _GdkArgContext
 {
-  XIC xic;
-  GdkICAttr *attr;
-  GdkICAttributesType mask;
+  GPtrArray *tables;
+  gpointer cb_data;
 };
 
-#endif /* USE_XIM */
-
-struct _GdkRegionPrivate
+struct _GdkArgDesc
 {
-  GdkRegion region;
-  Region xregion;
+  const char *name;
+  GdkArgType type;
+  gpointer location;
+  GdkArgFunc callback;
 };
 
+
 typedef enum {
   GDK_DEBUG_MISC          = 1 << 0,
   GDK_DEBUG_EVENTS        = 1 << 1,
@@ -249,28 +199,43 @@ typedef enum {
   GDK_DEBUG_XIM           = 1 << 4
 } GdkDebugFlag;
 
-void gdk_events_init (void);
+void gdk_event_button_generate (GdkEvent *event);
+
+/* FIFO's for event queue, and for events put back using
+ * gdk_event_put().
+ */
+extern GList *gdk_queued_events;
+extern GList *gdk_queued_tail;
+
+extern GdkEventFunc   gdk_event_func;    /* Callback for events */
+extern gpointer       gdk_event_data;
+extern GDestroyNotify gdk_event_notify;
+
+GdkEvent* gdk_event_new (void);
+
+void      gdk_events_init   (void);
+void      gdk_events_queue  (void);
+GdkEvent* gdk_event_unqueue (void);
+
+GList* gdk_event_queue_find_first  (void);
+void   gdk_event_queue_remove_link (GList    *node);
+void   gdk_event_queue_append      (GdkEvent *event);
+
 void gdk_window_init (void);
 void gdk_visual_init (void);
 void gdk_dnd_init    (void);
 
 void gdk_image_init  (void);
-void gdk_image_exit (void);
+void gdk_image_exit  (void);
 
-GdkColormap* gdk_colormap_lookup (Colormap  xcolormap);
-GdkVisual*   gdk_visual_lookup  (Visual   *xvisual);
+void gdk_input_init  (void);
+void gdk_input_exit  (void);
+
+void gdk_windowing_exit (void);
 
 void gdk_window_add_colormap_windows (GdkWindow *window);
 void gdk_window_destroy_notify      (GdkWindow *window);
 
-void    gdk_xid_table_insert (XID      *xid,
-                              gpointer  data);
-void    gdk_xid_table_remove (XID       xid);
-gpointer gdk_xid_table_lookup (XID      xid);
-
-gint gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
-                     XEvent *event_send);
-
 /* If you pass x = y = -1, it queries the pointer
    to find out where it currently is.
    If you pass x = y = -2, it does anything necessary
@@ -281,47 +246,32 @@ void gdk_dnd_display_drag_cursor(gint x,
                                 gboolean drag_ok,
                                 gboolean change_made);
 
-/* Please see gdkwindow.c for comments on how to use */ 
-Window gdk_window_xid_at(Window base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
-Window gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
-
 extern gint             gdk_debug_level;
-extern gint             gdk_show_events;
-extern gint             gdk_use_xshm;
-extern gint             gdk_stack_trace;
-extern gchar           *gdk_display_name;
-extern Display         *gdk_display;
+extern gboolean                 gdk_show_events;
 extern gint             gdk_screen;
-extern Window           gdk_root_window;
-extern Window           gdk_leader_window;
-extern GdkWindowPrivate         gdk_root_parent;
-extern Atom             gdk_wm_delete_window;
-extern Atom             gdk_wm_take_focus;
-extern Atom             gdk_wm_protocols;
-extern Atom             gdk_wm_window_protocols[];
-extern Atom             gdk_selection_property;
-extern GdkDndGlobals    gdk_dnd;
-extern GdkWindow       *selection_owner[];
-extern gchar           *gdk_progclass;
+extern GdkWindow       *gdk_parent_root;
 extern gint             gdk_error_code;
 extern gint             gdk_error_warnings;
-extern gint              gdk_null_window_warnings;
 extern GList            *gdk_default_filters;
-extern const int         gdk_nevent_masks;
-extern const int         gdk_event_mask_table[];
 
-extern GdkWindowPrivate *gdk_xgrab_window;  /* Window that currently holds the
-                                            * x pointer grab
-                                            */
+GdkWindow* _gdk_window_alloc (void);
+
+/* Font/string functions implemented in module-specific code */
+gint _gdk_font_strlen (GdkFont *font, const char *str);
+void _gdk_font_destroy (GdkFont *font);
+
+void _gdk_colormap_real_destroy (GdkColormap *colormap);
+
+/* Initialization */
+
+extern GdkArgDesc _gdk_windowing_args[];
+gboolean _gdk_windowing_init_check (int argc, char **argv);
 
 #ifdef USE_XIM
 /* XIM support */
 gint   gdk_im_open              (void);
 void   gdk_im_close             (void);
 void   gdk_ic_cleanup           (void);
-
-extern GdkICPrivate *gdk_xim_ic;               /* currently using IC */
-extern GdkWindow *gdk_xim_window;              /* currently using Window */
 #endif /* USE_XIM */
 
 /* Debugging support */
diff --git a/gdk/gdkproperty.c b/gdk/gdkproperty.c
deleted file mode 100644 (file)
index b91b787..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <string.h>
-
-#include "gdkx.h"
-#include "gdkproperty.h"
-#include "gdkprivate.h"
-
-GdkAtom
-gdk_atom_intern (const gchar *atom_name,
-                gint         only_if_exists)
-{
-  GdkAtom retval;
-  static GHashTable *atom_hash = NULL;
-  
-  if (!atom_hash)
-    atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
-  retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
-  if (!retval)
-    {
-      retval = XInternAtom (gdk_display, atom_name, only_if_exists);
-
-      if (retval != None)
-       g_hash_table_insert (atom_hash, 
-                            g_strdup (atom_name), 
-                            GUINT_TO_POINTER (retval));
-    }
-
-  return retval;
-}
-
-gchar*
-gdk_atom_name (GdkAtom atom)
-{
-  gchar *t;
-  gchar *name;
-  gint old_error_warnings;
-
-  /* If this atom doesn't exist, we'll die with an X error unless
-     we take precautions */
-
-  old_error_warnings = gdk_error_warnings;
-  gdk_error_warnings = 0;
-  gdk_error_code = 0;
-  t = XGetAtomName (gdk_display, atom);
-  gdk_error_warnings = old_error_warnings;
-
-  if (gdk_error_code)
-    {
-      if (t)
-       XFree (t);
-
-      return NULL;
-    }
-  else
-    {
-      name = g_strdup (t);
-      if (t)
-       XFree (t);
-      
-      return name;
-    }
-}
-
-gint
-gdk_property_get (GdkWindow   *window,
-                 GdkAtom      property,
-                 GdkAtom      type,
-                 gulong       offset,
-                 gulong       length,
-                 gint         pdelete,
-                 GdkAtom     *actual_property_type,
-                 gint        *actual_format_type,
-                 gint        *actual_length,
-                 guchar     **data)
-{
-  Display *xdisplay;
-  Window xwindow;
-  Atom ret_prop_type;
-  gint ret_format;
-  gulong ret_nitems;
-  gulong ret_bytes_after;
-  gulong ret_length;
-  guchar *ret_data;
-
-  if (window)
-    {
-      if (GDK_DRAWABLE_DESTROYED (window))
-       return FALSE;
-
-      xdisplay = GDK_WINDOW_XDISPLAY (window);
-      xwindow = GDK_WINDOW_XWINDOW (window);
-    }
-  else
-    {
-      xdisplay = gdk_display;
-      xwindow = gdk_root_window;
-    }
-
-  ret_data = NULL;
-  XGetWindowProperty (xdisplay, xwindow, property,
-                     offset, (length + 3) / 4, pdelete,
-                     type, &ret_prop_type, &ret_format,
-                     &ret_nitems, &ret_bytes_after,
-                     &ret_data);
-
-  if ((ret_prop_type == None) && (ret_format == 0)) {
-    return FALSE;
-  }
-
-  if (actual_property_type)
-    *actual_property_type = ret_prop_type;
-  if (actual_format_type)
-    *actual_format_type = ret_format;
-
-  if ((type != AnyPropertyType) && (ret_prop_type != type))
-    {
-      gchar *rn, *pn;
-
-      XFree (ret_data);
-      rn = gdk_atom_name(ret_prop_type);
-      pn = gdk_atom_name(type);
-      g_warning("Couldn't match property type %s to %s\n", rn, pn);
-      g_free(rn); g_free(pn);
-      return FALSE;
-    }
-
-  /* FIXME: ignoring bytes_after could have very bad effects */
-
-  if (data)
-    {
-      switch (ret_format)
-       {
-       case 8:
-         ret_length = ret_nitems;
-         break;
-       case 16:
-         ret_length = sizeof(short) * ret_nitems;
-         break;
-       case 32:
-         ret_length = sizeof(long) * ret_nitems;
-         break;
-       default:
-         g_warning ("unknown property return format: %d", ret_format);
-         XFree (ret_data);
-         return FALSE;
-       }
-
-      *data = g_new (guchar, ret_length);
-      memcpy (*data, ret_data, ret_length);
-      if (actual_length)
-       *actual_length = ret_length;
-    }
-
-  XFree (ret_data);
-
-  return TRUE;
-}
-
-void
-gdk_property_change (GdkWindow   *window,
-                    GdkAtom      property,
-                    GdkAtom      type,
-                    gint         format,
-                    GdkPropMode  mode,
-                    guchar      *data,
-                    gint         nelements)
-{
-  Display *xdisplay;
-  Window xwindow;
-
-  if (window)
-    {
-      if (GDK_DRAWABLE_DESTROYED (window))
-       return;
-
-      xdisplay = GDK_WINDOW_XDISPLAY (window);
-      xwindow = GDK_WINDOW_XWINDOW (window);
-    }
-  else
-    {
-      xdisplay = gdk_display;
-      xwindow = gdk_root_window;
-    }
-
-  XChangeProperty (xdisplay, xwindow, property, type,
-                  format, mode, data, nelements);
-}
-
-void
-gdk_property_delete (GdkWindow *window,
-                    GdkAtom    property)
-{
-  Display *xdisplay;
-  Window xwindow;
-
-  if (window)
-    {
-      if (GDK_DRAWABLE_DESTROYED (window))
-       return;
-
-      xdisplay = GDK_WINDOW_XDISPLAY (window);
-      xwindow = GDK_WINDOW_XWINDOW (window);
-    }
-  else
-    {
-      xdisplay = gdk_display;
-      xwindow = gdk_root_window;
-    }
-
-  XDeleteProperty (xdisplay, xwindow, property);
-}
diff --git a/gdk/gdkregion.c b/gdk/gdkregion.c
deleted file mode 100644 (file)
index d09f388..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include "gdk.h"
-#include "gdkprivate.h"
-
-
-
-
-GdkRegion*
-gdk_region_new (void)
-{
-  GdkRegionPrivate *private;
-  GdkRegion *region;
-  Region xregion;
-
-  xregion = XCreateRegion();
-  private = g_new (GdkRegionPrivate, 1);
-  private->xregion = xregion;
-  region = (GdkRegion*) private;
-  region->user_data = NULL;
-
-  return region;
-}
-
-void
-gdk_region_destroy (GdkRegion *region)
-{
-  GdkRegionPrivate *private;
-
-  g_return_if_fail (region != NULL);
-
-  private = (GdkRegionPrivate *) region;
-  XDestroyRegion (private->xregion);
-
-  g_free (private);
-}
-
-gboolean
-gdk_region_empty (GdkRegion      *region)
-{
-  GdkRegionPrivate *private;
-
-  g_return_val_if_fail (region != NULL, 0);
-
-  private = (GdkRegionPrivate *) region;
-  
-  return XEmptyRegion (private->xregion);
-}
-
-gboolean
-gdk_region_equal (GdkRegion      *region1,
-                  GdkRegion      *region2)
-{
-  GdkRegionPrivate *private1;
-  GdkRegionPrivate *private2;
-
-  g_return_val_if_fail (region1 != NULL, 0);
-  g_return_val_if_fail (region2 != NULL, 0);
-
-  private1 = (GdkRegionPrivate *) region1;
-  private2 = (GdkRegionPrivate *) region2;
-  
-  return XEqualRegion (private1->xregion, private2->xregion);
-}
-
-void
-gdk_region_get_clipbox(GdkRegion    *region,
-                      GdkRectangle *rectangle)
-{
-       GdkRegionPrivate *rp;
-       XRectangle r;
-
-       g_return_if_fail(region != NULL);
-       g_return_if_fail(rectangle != NULL);
-
-       rp = (GdkRegionPrivate *)region;
-       XClipBox(rp->xregion, &r);
-
-       rectangle->x = r.x;
-       rectangle->y = r.y;     
-       rectangle->width = r.width;
-       rectangle->height = r.height;
-}
-
-gboolean
-gdk_region_point_in (GdkRegion      *region,
-                     gint           x,
-                    gint           y)
-{
-  GdkRegionPrivate *private;
-
-  g_return_val_if_fail (region != NULL, 0);
-
-  private = (GdkRegionPrivate *) region;
-  
-  return XPointInRegion (private->xregion, x, y);
-}
-
-GdkOverlapType
-gdk_region_rect_in (GdkRegion      *region,
-                    GdkRectangle   *rect)
-{
-  GdkRegionPrivate *private;
-  int res;
-
-  g_return_val_if_fail (region != NULL, 0);
-
-  private = (GdkRegionPrivate *) region;
-  
-  res = XRectInRegion (private->xregion, rect->x, rect->y, rect->width, rect->height);
-  
-  switch (res)
-  {
-    case RectangleIn:   return GDK_OVERLAP_RECTANGLE_IN;
-    case RectangleOut:  return GDK_OVERLAP_RECTANGLE_OUT;
-    case RectanglePart: return GDK_OVERLAP_RECTANGLE_PART;
-  }
-  
-  return GDK_OVERLAP_RECTANGLE_OUT;  /*what else ? */
-}
-                                   
-GdkRegion *
-gdk_region_polygon (GdkPoint    *points,
-                   gint         npoints,
-                   GdkFillRule  fill_rule)
-{
-  GdkRegionPrivate *private;
-  GdkRegion *region;
-  Region xregion;
-  gint xfill_rule = EvenOddRule;
-
-  g_return_val_if_fail (points != NULL, NULL);
-  g_return_val_if_fail (npoints != 0, NULL); /* maybe we should check for at least three points */
-
-  switch (fill_rule)
-    {
-    case GDK_EVEN_ODD_RULE:
-      xfill_rule = EvenOddRule;
-      break;
-
-    case GDK_WINDING_RULE:
-      xfill_rule = WindingRule;
-      break;
-    }
-
-  xregion = XPolygonRegion ((XPoint *) points, npoints, xfill_rule);
-  private = g_new (GdkRegionPrivate, 1);
-  private->xregion = xregion;
-  region = (GdkRegion *) private;
-  region->user_data = NULL;
-
-  return region;
-}
-
-void          
-gdk_region_offset (GdkRegion      *region,
-                   gint           dx,
-                  gint           dy)
-{
-  GdkRegionPrivate *private;
-
-  g_return_if_fail (region != NULL);
-
-  private = (GdkRegionPrivate *) region;
-  
-  XOffsetRegion (private->xregion, dx, dy);
-}
-
-void
-gdk_region_shrink (GdkRegion      *region,
-                   gint           dx,
-                  gint           dy)
-{
-  GdkRegionPrivate *private;
-
-  g_return_if_fail (region != NULL);
-
-  private = (GdkRegionPrivate *) region;
-  
-  XShrinkRegion (private->xregion, dx, dy);
-}
-
-GdkRegion*    
-gdk_region_union_with_rect (GdkRegion      *region,
-                            GdkRectangle   *rect)
-{
-  GdkRegionPrivate *private;
-  GdkRegion *res;
-  GdkRegionPrivate *res_private;
-  XRectangle xrect;
-
-  g_return_val_if_fail (region != NULL, NULL);
-
-  private = (GdkRegionPrivate *) region;
-  
-  xrect.x = rect->x;
-  xrect.y = rect->y;
-  xrect.width = rect->width;
-  xrect.height = rect->height;
-  
-  res = gdk_region_new ();
-  res_private = (GdkRegionPrivate *) res;
-  
-  XUnionRectWithRegion (&xrect, private->xregion, res_private->xregion);
-  
-  return res;
-}
-
-GdkRegion*    
-gdk_regions_intersect (GdkRegion      *source1,
-                       GdkRegion      *source2)
-{
-  GdkRegionPrivate *private1;
-  GdkRegionPrivate *private2;
-  GdkRegion *res;
-  GdkRegionPrivate *res_private;
-
-  g_return_val_if_fail (source1 != NULL, NULL);
-  g_return_val_if_fail (source2 != NULL, NULL);
-
-  private1 = (GdkRegionPrivate *) source1;
-  private2 = (GdkRegionPrivate *) source2;
-
-  res = gdk_region_new ();
-  res_private = (GdkRegionPrivate *) res;
-  
-  XIntersectRegion (private1->xregion, private2->xregion, res_private->xregion);
-  
-  return res;
-}
-
-GdkRegion* 
-gdk_regions_union (GdkRegion      *source1,
-                   GdkRegion      *source2)
-{
-  GdkRegionPrivate *private1;
-  GdkRegionPrivate *private2;
-  GdkRegion *res;
-  GdkRegionPrivate *res_private;
-
-  g_return_val_if_fail (source1 != NULL, NULL);
-  g_return_val_if_fail (source2 != NULL, NULL);
-
-  private1 = (GdkRegionPrivate *) source1;
-  private2 = (GdkRegionPrivate *) source2;
-
-  res = gdk_region_new ();
-  res_private = (GdkRegionPrivate *) res;
-  
-  XUnionRegion (private1->xregion, private2->xregion, res_private->xregion);
-  
-  return res;
-}
-
-GdkRegion*    
-gdk_regions_subtract (GdkRegion      *source1,
-                      GdkRegion      *source2)
-{
-  GdkRegionPrivate *private1;
-  GdkRegionPrivate *private2;
-  GdkRegion *res;
-  GdkRegionPrivate *res_private;
-
-  g_return_val_if_fail (source1 != NULL, NULL);
-  g_return_val_if_fail (source2 != NULL, NULL);
-
-  private1 = (GdkRegionPrivate *) source1;
-  private2 = (GdkRegionPrivate *) source2;
-
-  res = gdk_region_new ();
-  res_private = (GdkRegionPrivate *) res;
-  
-  XSubtractRegion (private1->xregion, private2->xregion, res_private->xregion);
-  
-  return res;
-}
-
-GdkRegion*    
-gdk_regions_xor (GdkRegion      *source1,
-                 GdkRegion      *source2)
-{
-  GdkRegionPrivate *private1;
-  GdkRegionPrivate *private2;
-  GdkRegion *res;
-  GdkRegionPrivate *res_private;
-
-  g_return_val_if_fail (source1 != NULL, NULL);
-  g_return_val_if_fail (source2 != NULL, NULL);
-
-  private1 = (GdkRegionPrivate *) source1;
-  private2 = (GdkRegionPrivate *) source2;
-
-  res = gdk_region_new ();
-  res_private = (GdkRegionPrivate *) res;
-  
-  XXorRegion (private1->xregion, private2->xregion, res_private->xregion);
-  
-  return res;
-}
-
-
-
index b0624346ccd29ba11cd8549cb52bce7caebd1be8..17f9a09558e28e8e2acd9a8cc84f1a5c90adb1bc 100644 (file)
@@ -73,6 +73,16 @@ typedef void (*GdkRgbConvFunc) (GdkImage *image,
                                gint x_align, gint y_align,
                                GdkRgbCmap *cmap);
 
+static const gchar* visual_names[] =
+{
+  "static gray",
+  "grayscale",
+  "static color",
+  "pseudo color",
+  "true color",
+  "direct color",
+};
+
 /* Some of these fields should go, as they're not being used at all.
    Globals should generally migrate into here - it's very likely that
    we'll want to run more than one GdkRgbInfo context at the same time
@@ -405,16 +415,6 @@ static guint32
 gdk_rgb_score_visual (GdkVisual *visual)
 {
   guint32 quality, speed, sys, pseudo;
-  static const gchar* visual_names[] =
-  {
-    "static gray",
-    "grayscale",
-    "static color",
-    "pseudo color",
-    "true color",
-    "direct color",
-  };
-
 
   quality = 0;
   speed = 1;
@@ -466,8 +466,7 @@ gdk_rgb_score_visual (GdkVisual *visual)
   pseudo = (visual->type == GDK_VISUAL_PSEUDO_COLOR || visual->type == GDK_VISUAL_TRUE_COLOR);
 
   if (gdk_rgb_verbose)
-    g_print ("Visual 0x%x, type = %s, depth = %d, %x:%x:%x%s; score=%x\n",
-            (gint)(((GdkVisualPrivate *)visual)->xvisual->visualid),
+    g_print ("Visual type = %s, depth = %d, %x:%x:%x%s; score=%x\n",
             visual_names[visual->type],
             visual->depth,
             visual->red_mask,
@@ -2681,16 +2680,19 @@ gdk_rgb_select_conv (GdkImage *image)
   gboolean mask_rgb, mask_bgr;
 
   depth = image_info->visual->depth;
-#if defined (GDK_RGB_STANDALONE) || defined (GDK_WINDOWING_X11)
-  bpp = ((GdkImagePrivate *)image)->ximage->bits_per_pixel;
-#elif defined (GDK_WINDOWING_WIN32)
-  bpp = ((GdkVisualPrivate *) gdk_visual_get_system())->xvisual->bitspixel;
-#endif
+
+  /* FIXME: save the bpp in the image; this is hack that works for
+   *        common visuals, not otherwise.
+   */
+  if (depth <= 8)
+    bpp = depth;
+  else
+    bpp = 8 * image->bpp;
 
   byte_order = image->byte_order;
   if (gdk_rgb_verbose)
-    g_print ("Chose visual 0x%x, image bpp=%d, %s first\n",
-            (gint)(((GdkVisualPrivate *)image_info->visual)->xvisual->visualid),
+    g_print ("Chose visual type=%s depth=%d, image bpp=%d, %s first\n",
+            visual_names[image_info->visual->type], image_info->visual->depth,
             bpp, byte_order == GDK_LSB_FIRST ? "lsb" : "msb");
 
 #if G_BYTE_ORDER == G_BIG_ENDIAN
diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c
deleted file mode 100644 (file)
index e1272f4..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <string.h>
-
-#include "gdkproperty.h"
-#include "gdkselection.h"
-#include "gdkprivate.h"
-#include "gdkx.h"
-
-
-gint
-gdk_selection_owner_set (GdkWindow *owner,
-                        GdkAtom    selection,
-                        guint32    time,
-                        gint       send_event)
-{
-  Display *xdisplay;
-  Window xwindow;
-
-  if (owner)
-    {
-      if (GDK_DRAWABLE_DESTROYED (owner))
-       return FALSE;
-
-      xdisplay = GDK_DRAWABLE_XDISPLAY (owner);
-      xwindow = GDK_DRAWABLE_XID (owner);
-    }
-  else
-    {
-      xdisplay = gdk_display;
-      xwindow = None;
-    }
-
-  XSetSelectionOwner (xdisplay, selection, xwindow, time);
-
-  return (XGetSelectionOwner (xdisplay, selection) == xwindow);
-}
-
-GdkWindow*
-gdk_selection_owner_get (GdkAtom selection)
-{
-  Window xwindow;
-
-  xwindow = XGetSelectionOwner (gdk_display, selection);
-  if (xwindow == None)
-    return NULL;
-
-  return gdk_window_lookup (xwindow);
-}
-
-void
-gdk_selection_convert (GdkWindow *requestor,
-                      GdkAtom    selection,
-                      GdkAtom    target,
-                      guint32    time)
-{
-  if (GDK_DRAWABLE_DESTROYED (requestor))
-    return;
-
-  XConvertSelection (GDK_DRAWABLE_XDISPLAY (requestor), selection, target,
-                    gdk_selection_property, GDK_DRAWABLE_XID (requestor), time);
-}
-
-gint
-gdk_selection_property_get (GdkWindow  *requestor,
-                           guchar    **data,
-                           GdkAtom    *ret_type,
-                           gint       *ret_format)
-{
-  gulong nitems;
-  gulong nbytes;
-  gulong length;
-  GdkAtom prop_type;
-  gint prop_format;
-  guchar *t = NULL;
-
-  g_return_val_if_fail (requestor != NULL, 0);
-  g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0);
-
-  /* If retrieved chunks are typically small, (and the ICCCM says the
-     should be) it would be a win to try first with a buffer of
-     moderate length, to avoid two round trips to the server */
-
-  if (GDK_DRAWABLE_DESTROYED (requestor))
-    return 0;
-
-  t = NULL;
-  XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor),
-                     GDK_DRAWABLE_XID (requestor),
-                     gdk_selection_property, 0, 0, False,
-                     AnyPropertyType, &prop_type, &prop_format,
-                     &nitems, &nbytes, &t);
-
-  if (ret_type)
-    *ret_type = prop_type;
-  if (ret_format)
-    *ret_format = prop_format;
-
-  if (prop_type == None)
-    {
-      *data = NULL;
-      return 0;
-    }
-  
-  if (t)
-    {
-      XFree (t);
-      t = NULL;
-    }
-
-  /* Add on an extra byte to handle null termination.  X guarantees
-     that t will be 1 longer than nbytes and null terminated */
-  length = nbytes + 1;
-
-  /* We can't delete the selection here, because it might be the INCR
-     protocol, in which case the client has to make sure they'll be
-     notified of PropertyChange events _before_ the property is deleted.
-     Otherwise there's no guarantee we'll win the race ... */
-  XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor),
-                     GDK_DRAWABLE_XID (requestor),
-                     gdk_selection_property, 0, (nbytes + 3) / 4, False,
-                     AnyPropertyType, &prop_type, &prop_format,
-                     &nitems, &nbytes, &t);
-
-  if (prop_type != None)
-    {
-      *data = g_new (guchar, length);
-      memcpy (*data, t, length);
-      if (t)
-       XFree (t);
-      return length-1;
-    }
-  else
-    {
-      *data = NULL;
-      return 0;
-    }
-}
-
-
-void
-gdk_selection_send_notify (guint32  requestor,
-                          GdkAtom  selection,
-                          GdkAtom  target,
-                          GdkAtom  property,
-                          guint32  time)
-{
-  XSelectionEvent xevent;
-
-  xevent.type = SelectionNotify;
-  xevent.serial = 0;
-  xevent.send_event = True;
-  xevent.display = gdk_display;
-  xevent.requestor = requestor;
-  xevent.selection = selection;
-  xevent.target = target;
-  xevent.property = property;
-  xevent.time = time;
-
-  gdk_send_xevent (requestor, False, NoEventMask, (XEvent*) &xevent);
-}
-
-gint
-gdk_text_property_to_text_list (GdkAtom encoding, gint format, 
-                            guchar *text, gint length,
-                            gchar ***list)
-{
-  XTextProperty property;
-  gint count = 0;
-  gint res;
-
-  if (!list) 
-    return 0;
-
-  property.value = text;
-  property.encoding = encoding;
-  property.format = format;
-  property.nitems = length;
-  res = XmbTextPropertyToTextList (GDK_DISPLAY(), &property, list, &count);
-
-  if (res == XNoMemory || res == XLocaleNotSupported || 
-      res == XConverterNotFound)
-    return 0;
-  else
-    return count;
-}
-
-void
-gdk_free_text_list (gchar **list)
-{
-  g_return_if_fail (list != NULL);
-
-  XFreeStringList (list);
-}
-
-gint
-gdk_string_to_compound_text (gchar *str,
-                            GdkAtom *encoding, gint *format,
-                            guchar **ctext, gint *length)
-{
-  gint res;
-  XTextProperty property;
-
-  res = XmbTextListToTextProperty (GDK_DISPLAY(), 
-                                  &str, 1, XCompoundTextStyle,
-                                          &property);
-  if (res != Success)
-    {
-      property.encoding = None;
-      property.format = None;
-      property.value = NULL;
-      property.nitems = 0;
-    }
-
-  if (encoding)
-    *encoding = property.encoding;
-  if (format)
-    *format = property.format;
-  if (ctext)
-    *ctext = property.value;
-  if (length)
-    *length = property.nitems;
-
-  return res;
-}
-
-void gdk_free_compound_text (guchar *ctext)
-{
-  if (ctext)
-    XFree (ctext);
-}
diff --git a/gdk/gdkvisual.c b/gdk/gdkvisual.c
deleted file mode 100644 (file)
index 072ff45..0000000
+++ /dev/null
@@ -1,452 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include "gdkvisual.h"
-#include "gdkprivate.h"
-
-static void  gdk_visual_add            (GdkVisual *visual);
-static void  gdk_visual_decompose_mask (gulong     mask,
-                                       gint      *shift,
-                                       gint      *prec);
-static guint gdk_visual_hash           (Visual    *key);
-static gint  gdk_visual_compare        (Visual    *a,
-                                       Visual    *b);
-
-
-static GdkVisualPrivate *system_visual;
-static GdkVisualPrivate *visuals;
-static gint nvisuals;
-
-static gint available_depths[7];
-static gint navailable_depths;
-
-static GdkVisualType available_types[6];
-static gint navailable_types;
-
-#ifdef G_ENABLE_DEBUG
-
-static const gchar* visual_names[] =
-{
-  "static gray",
-  "grayscale",
-  "static color",
-  "pseudo color",
-  "true color",
-  "direct color",
-};
-
-#endif /* G_ENABLE_DEBUG */
-
-static GHashTable *visual_hash = NULL;
-
-void
-gdk_visual_init (void)
-{
-  static const gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 };
-  static const GdkVisualType possible_types[6] =
-    {
-      GDK_VISUAL_DIRECT_COLOR,
-      GDK_VISUAL_TRUE_COLOR,
-      GDK_VISUAL_PSEUDO_COLOR,
-      GDK_VISUAL_STATIC_COLOR,
-      GDK_VISUAL_GRAYSCALE,
-      GDK_VISUAL_STATIC_GRAY
-    };
-
-  static const gint npossible_depths = sizeof(possible_depths)/sizeof(gint);
-  static const gint npossible_types = sizeof(possible_types)/sizeof(GdkVisualType);
-
-  XVisualInfo *visual_list;
-  XVisualInfo visual_template;
-  GdkVisualPrivate temp_visual;
-  Visual *default_xvisual;
-  int nxvisuals;
-  int i, j;
-
-  visual_template.screen = gdk_screen;
-  visual_list = XGetVisualInfo (gdk_display, VisualScreenMask, &visual_template, &nxvisuals);
-  visuals = g_new (GdkVisualPrivate, nxvisuals);
-
-  default_xvisual = DefaultVisual (gdk_display, gdk_screen);
-
-  nvisuals = 0;
-  for (i = 0; i < nxvisuals; i++)
-    {
-      if (visual_list[i].depth >= 1)
-       {
-#ifdef __cplusplus
-         switch (visual_list[i].c_class)
-#else /* __cplusplus */
-         switch (visual_list[i].class)
-#endif /* __cplusplus */
-           {
-           case StaticGray:
-             visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_GRAY;
-             break;
-           case GrayScale:
-             visuals[nvisuals].visual.type = GDK_VISUAL_GRAYSCALE;
-             break;
-           case StaticColor:
-             visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_COLOR;
-             break;
-           case PseudoColor:
-             visuals[nvisuals].visual.type = GDK_VISUAL_PSEUDO_COLOR;
-             break;
-           case TrueColor:
-             visuals[nvisuals].visual.type = GDK_VISUAL_TRUE_COLOR;
-             break;
-           case DirectColor:
-             visuals[nvisuals].visual.type = GDK_VISUAL_DIRECT_COLOR;
-             break;
-           }
-
-         visuals[nvisuals].visual.depth = visual_list[i].depth;
-         visuals[nvisuals].visual.byte_order =
-           (ImageByteOrder(gdk_display) == LSBFirst) ?
-           GDK_LSB_FIRST : GDK_MSB_FIRST;
-         visuals[nvisuals].visual.red_mask = visual_list[i].red_mask;
-         visuals[nvisuals].visual.green_mask = visual_list[i].green_mask;
-         visuals[nvisuals].visual.blue_mask = visual_list[i].blue_mask;
-         visuals[nvisuals].visual.colormap_size = visual_list[i].colormap_size;
-         visuals[nvisuals].visual.bits_per_rgb = visual_list[i].bits_per_rgb;
-         visuals[nvisuals].xvisual = visual_list[i].visual;
-
-         if ((visuals[nvisuals].visual.type == GDK_VISUAL_TRUE_COLOR) ||
-             (visuals[nvisuals].visual.type == GDK_VISUAL_DIRECT_COLOR))
-           {
-             gdk_visual_decompose_mask (visuals[nvisuals].visual.red_mask,
-                                        &visuals[nvisuals].visual.red_shift,
-                                        &visuals[nvisuals].visual.red_prec);
-
-             gdk_visual_decompose_mask (visuals[nvisuals].visual.green_mask,
-                                        &visuals[nvisuals].visual.green_shift,
-                                        &visuals[nvisuals].visual.green_prec);
-
-             gdk_visual_decompose_mask (visuals[nvisuals].visual.blue_mask,
-                                        &visuals[nvisuals].visual.blue_shift,
-                                        &visuals[nvisuals].visual.blue_prec);
-           }
-         else
-           {
-             visuals[nvisuals].visual.red_mask = 0;
-             visuals[nvisuals].visual.red_shift = 0;
-             visuals[nvisuals].visual.red_prec = 0;
-
-             visuals[nvisuals].visual.green_mask = 0;
-             visuals[nvisuals].visual.green_shift = 0;
-             visuals[nvisuals].visual.green_prec = 0;
-
-             visuals[nvisuals].visual.blue_mask = 0;
-             visuals[nvisuals].visual.blue_shift = 0;
-             visuals[nvisuals].visual.blue_prec = 0;
-           }
-
-         nvisuals += 1;
-       }
-    }
-
-  if (visual_list)
-    XFree (visual_list);
-
-  for (i = 0; i < nvisuals; i++)
-    {
-      for (j = i+1; j < nvisuals; j++)
-       {
-         if (visuals[j].visual.depth >= visuals[i].visual.depth)
-           {
-             if ((visuals[j].visual.depth == 8) && (visuals[i].visual.depth == 8))
-               {
-                 if (visuals[j].visual.type == GDK_VISUAL_PSEUDO_COLOR)
-                   {
-                     temp_visual = visuals[j];
-                     visuals[j] = visuals[i];
-                     visuals[i] = temp_visual;
-                   }
-                 else if ((visuals[i].visual.type != GDK_VISUAL_PSEUDO_COLOR) &&
-                          visuals[j].visual.type > visuals[i].visual.type)
-                   {
-                     temp_visual = visuals[j];
-                     visuals[j] = visuals[i];
-                     visuals[i] = temp_visual;
-                   }
-               }
-             else if ((visuals[j].visual.depth > visuals[i].visual.depth) ||
-                      ((visuals[j].visual.depth == visuals[i].visual.depth) &&
-                       (visuals[j].visual.type > visuals[i].visual.type)))
-               {
-                 temp_visual = visuals[j];
-                 visuals[j] = visuals[i];
-                 visuals[i] = temp_visual;
-               }
-           }
-       }
-    }
-
-  for (i = 0; i < nvisuals; i++)
-    if (default_xvisual->visualid == visuals[i].xvisual->visualid)
-      {
-       system_visual = &visuals[i];
-       break;
-      }
-
-#ifdef G_ENABLE_DEBUG 
-  if (gdk_debug_flags & GDK_DEBUG_MISC)
-    for (i = 0; i < nvisuals; i++)
-      g_message ("visual: %s: %d",
-                visual_names[visuals[i].visual.type],
-                visuals[i].visual.depth);
-#endif /* G_ENABLE_DEBUG */
-
-  navailable_depths = 0;
-  for (i = 0; i < npossible_depths; i++)
-    {
-      for (j = 0; j < nvisuals; j++)
-       {
-         if (visuals[j].visual.depth == possible_depths[i])
-           {
-             available_depths[navailable_depths++] = visuals[j].visual.depth;
-             break;
-           }
-       }
-    }
-
-  if (navailable_depths == 0)
-    g_error ("unable to find a usable depth");
-
-  navailable_types = 0;
-  for (i = 0; i < npossible_types; i++)
-    {
-      for (j = 0; j < nvisuals; j++)
-       {
-         if (visuals[j].visual.type == possible_types[i])
-           {
-             available_types[navailable_types++] = visuals[j].visual.type;
-             break;
-           }
-       }
-    }
-
-  for (i = 0; i < nvisuals; i++)
-    gdk_visual_add ((GdkVisual*) &visuals[i]);
-
-  if (npossible_types == 0)
-    g_error ("unable to find a usable visual type");
-}
-
-GdkVisual*
-gdk_visual_ref (GdkVisual *visual)
-{
-  return visual;
-}
-
-void
-gdk_visual_unref (GdkVisual *visual)
-{
-  return;
-}
-
-gint
-gdk_visual_get_best_depth (void)
-{
-  return available_depths[0];
-}
-
-GdkVisualType
-gdk_visual_get_best_type (void)
-{
-  return available_types[0];
-}
-
-GdkVisual*
-gdk_visual_get_system (void)
-{
-  return ((GdkVisual*) system_visual);
-}
-
-GdkVisual*
-gdk_visual_get_best (void)
-{
-  return ((GdkVisual*) &(visuals[0]));
-}
-
-GdkVisual*
-gdk_visual_get_best_with_depth (gint depth)
-{
-  GdkVisual *return_val;
-  int i;
-
-  return_val = NULL;
-  for (i = 0; i < nvisuals; i++)
-    if (depth == visuals[i].visual.depth)
-      {
-       return_val = (GdkVisual*) &(visuals[i]);
-       break;
-      }
-
-  return return_val;
-}
-
-GdkVisual*
-gdk_visual_get_best_with_type (GdkVisualType visual_type)
-{
-  GdkVisual *return_val;
-  int i;
-
-  return_val = NULL;
-  for (i = 0; i < nvisuals; i++)
-    if (visual_type == visuals[i].visual.type)
-      {
-       return_val = (GdkVisual*) &(visuals[i]);
-       break;
-      }
-
-  return return_val;
-}
-
-GdkVisual*
-gdk_visual_get_best_with_both (gint          depth,
-                              GdkVisualType visual_type)
-{
-  GdkVisual *return_val;
-  int i;
-
-  return_val = NULL;
-  for (i = 0; i < nvisuals; i++)
-    if ((depth == visuals[i].visual.depth) &&
-       (visual_type == visuals[i].visual.type))
-      {
-       return_val = (GdkVisual*) &(visuals[i]);
-       break;
-      }
-
-  return return_val;
-}
-
-void
-gdk_query_depths  (gint **depths,
-                  gint  *count)
-{
-  *count = navailable_depths;
-  *depths = available_depths;
-}
-
-void
-gdk_query_visual_types (GdkVisualType **visual_types,
-                       gint           *count)
-{
-  *count = navailable_types;
-  *visual_types = available_types;
-}
-
-GList*
-gdk_list_visuals (void)
-{
-  GList *list;
-  guint i;
-
-  list = NULL;
-  for (i = 0; i < nvisuals; ++i)
-    list = g_list_append (list, (gpointer) &visuals[i]);
-
-  return list;
-}
-
-
-GdkVisual*
-gdk_visual_lookup (Visual *xvisual)
-{
-  GdkVisual *visual;
-
-  if (!visual_hash)
-    return NULL;
-
-  visual = g_hash_table_lookup (visual_hash, xvisual);
-  return visual;
-}
-
-GdkVisual*
-gdkx_visual_get (VisualID xvisualid)
-{
-  int i;
-
-  for (i = 0; i < nvisuals; i++)
-    if (xvisualid == visuals[i].xvisual->visualid)
-      return (GdkVisual*) &visuals[i];
-
-  return NULL;
-}
-
-
-static void
-gdk_visual_add (GdkVisual *visual)
-{
-  GdkVisualPrivate *private;
-
-  if (!visual_hash)
-    visual_hash = g_hash_table_new ((GHashFunc) gdk_visual_hash,
-                                   (GCompareFunc) gdk_visual_compare);
-
-  private = (GdkVisualPrivate*) visual;
-
-  g_hash_table_insert (visual_hash, private->xvisual, visual);
-}
-
-static void
-gdk_visual_decompose_mask (gulong  mask,
-                          gint   *shift,
-                          gint   *prec)
-{
-  *shift = 0;
-  *prec = 0;
-
-  while (!(mask & 0x1))
-    {
-      (*shift)++;
-      mask >>= 1;
-    }
-
-  while (mask & 0x1)
-    {
-      (*prec)++;
-      mask >>= 1;
-    }
-}
-
-static guint
-gdk_visual_hash (Visual *key)
-{
-  return key->visualid;
-}
-
-static gint
-gdk_visual_compare (Visual *a,
-                   Visual *b)
-{
-  return (a->visualid == b->visualid);
-}
index 16bdb37d7ce8e77ee25b19c7ccb9bfc0670dab76..1e1a947ebd15d3f414ebb1622b4ededf120913c6 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-#include <netinet/in.h>
-#include "gdk.h"
-#include "config.h"
-
 #include "gdkwindow.h"
-#include "gdkinputprivate.h"
 #include "gdkprivate.h"
-#include "gdkx.h"
-#include "MwmUtil.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-
-#ifdef HAVE_SHAPE_EXT
-#include <X11/extensions/shape.h>
-#endif
 
-const int gdk_event_mask_table[20] =
-{
-  ExposureMask,
-  PointerMotionMask,
-  PointerMotionHintMask,
-  ButtonMotionMask,
-  Button1MotionMask,
-  Button2MotionMask,
-  Button3MotionMask,
-  ButtonPressMask | OwnerGrabButtonMask,
-  ButtonReleaseMask | OwnerGrabButtonMask,
-  KeyPressMask,
-  KeyReleaseMask,
-  EnterWindowMask,
-  LeaveWindowMask,
-  FocusChangeMask,
-  StructureNotifyMask,
-  PropertyChangeMask,
-  VisibilityChangeMask,
-  0,                           /* PROXIMITY_IN */
-  0,                           /* PROXIMTY_OUT */
-  SubstructureNotifyMask
-};
-const int gdk_nevent_masks = sizeof (gdk_event_mask_table) / sizeof (int);
-
-/* Forward declarations */
-static gboolean gdk_window_gravity_works (void);
-static void     gdk_window_set_static_win_gravity (GdkWindow *window, 
-                                                  gboolean   on);
-static gboolean gdk_window_have_shape_ext (void);
-
-/* internal function created for and used by gdk_window_xid_at_coords */
-Window
-gdk_window_xid_at (Window   base,
-                  gint     bx,
-                  gint     by,
-                  gint     x,
-                  gint     y, 
-                  GList   *excludes,
-                  gboolean excl_child)
+GdkWindow *
+_gdk_window_alloc (void)
 {
-  GdkWindow *window;
-  GdkDrawablePrivate *private;
-  Display *disp;
-  Window *list = NULL;
-  Window child = 0, parent_win = 0, root_win = 0;
-  int i;
-  unsigned int ww, wh, wb, wd, num;
-  int wx, wy;
+  GdkWindowPrivate *private = g_new (GdkWindowPrivate, 1);
+  GdkWindow *window = (GdkWindow*) private;
   
-  window = (GdkWindow*) &gdk_root_parent;
-  private = (GdkDrawablePrivate*) window;
-  disp = private->xdisplay;
-  if (!XGetGeometry (disp, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd))
-    return 0;
-  wx += bx;
-  wy += by;
-  
-  if (!((x >= wx) &&
-       (y >= wy) &&
-       (x < (int) (wx + ww)) &&
-       (y < (int) (wy + wh))))
-    return 0;
-  
-  if (!XQueryTree (disp, base, &root_win, &parent_win, &list, &num))
-    return base;
-  
-  if (list)
-    {
-      for (i = num - 1; ; i--)
-       {
-         if ((!excl_child) || (!g_list_find (excludes, (gpointer *) list[i])))
-           {
-             if ((child = gdk_window_xid_at (list[i], wx, wy, x, y, excludes, excl_child)) != 0)
-               {
-                 XFree (list);
-                 return child;
-               }
-           }
-         if (!i)
-           break;
-       }
-      XFree (list);
-    }
-  return base;
-}
+  window->user_data = NULL;
 
-/* 
- * The following fucntion by The Rasterman <raster@redhat.com>
- * This function returns the X Window ID in which the x y location is in 
- * (x and y being relative to the root window), excluding any windows listed
- * in the GList excludes (this is a list of X Window ID's - gpointer being
- * the Window ID).
- * 
- * This is primarily designed for internal gdk use - for DND for example
- * when using a shaped icon window as the drag object - you exclude the
- * X Window ID of the "icon" (perhaps more if excludes may be needed) and
- * You can get back an X Window ID as to what X Window ID is infact under
- * those X,Y co-ordinates.
- */
-Window
-gdk_window_xid_at_coords (gint     x,
-                         gint     y,
-                         GList   *excludes,
-                         gboolean excl_child)
-{
-  GdkWindow *window;
-  GdkDrawablePrivate *private;
-  Display *disp;
-  Window *list = NULL;
-  Window root, child = 0, parent_win = 0, root_win = 0;
-  unsigned int num;
-  int i;
+  private->drawable.ref_count = 1;
+  private->drawable.destroyed = FALSE;
+  private->drawable.klass = NULL;
+  private->drawable.klass_data = NULL;
+  private->drawable.window_type = GDK_WINDOW_CHILD;
 
-  window = (GdkWindow*) &gdk_root_parent;
-  private = (GdkDrawablePrivate*) window;
-  disp = private->xdisplay;
-  root = private->xwindow;
-  num = g_list_length (excludes);
-  
-  XGrabServer (disp);
-  if (!XQueryTree (disp, root, &root_win, &parent_win, &list, &num))
-    {
-      XUngrabServer (disp);
-      return root;
-    }
-  if (list)
-    {
-      i = num - 1;
-      do
-       {
-         XWindowAttributes xwa;
-         
-         XGetWindowAttributes (disp, list [i], &xwa);
-         
-         if (xwa.map_state != IsViewable)
-           continue;
-         
-         if (excl_child && g_list_find (excludes, (gpointer *) list[i]))
-           continue;
-         
-         if ((child = gdk_window_xid_at (list[i], 0, 0, x, y, excludes, excl_child)) == 0)
-           continue;
-         
-         if (excludes)
-           {
-             if (!g_list_find (excludes, (gpointer *) child))
-               {
-                 XFree (list);
-                 XUngrabServer (disp);
-                 return child;
-               }
-           }
-         else
-           {
-             XFree (list);
-             XUngrabServer (disp);
-             return child;
-           }
-       } while (--i > 0);
-      XFree (list);
-    }
-  XUngrabServer (disp);
-  return root;
-}
+  private->drawable.width = 1;
+  private->drawable.height = 1;
 
-void
-gdk_window_init (void)
-{
-  XWindowAttributes xattributes;
-  unsigned int width;
-  unsigned int height;
-  unsigned int border_width;
-  unsigned int depth;
-  int x, y;
-  
-  XGetGeometry (gdk_display, gdk_root_window, &gdk_root_window,
-               &x, &y, &width, &height, &border_width, &depth);
-  XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes);
-  
-  gdk_root_parent.drawable.xwindow = gdk_root_window;
-  gdk_root_parent.drawable.xdisplay = gdk_display;
-  gdk_root_parent.drawable.window_type = GDK_WINDOW_ROOT;
-  gdk_root_parent.drawable.drawable.user_data = NULL;
-  gdk_root_parent.drawable.width = width;
-  gdk_root_parent.drawable.height = height;
-  gdk_root_parent.children = NULL;
-  gdk_root_parent.drawable.colormap = NULL;
-  gdk_root_parent.drawable.ref_count = 1;
-  
-  gdk_xid_table_insert (&gdk_root_window, &gdk_root_parent);
-}
+  private->drawable.colormap = NULL;
 
-static GdkAtom wm_client_leader_atom = GDK_NONE;
+  private->parent = NULL;
+  private->x = 0;
+  private->y = 0;
+  private->resize_count = 0;
 
-GdkWindow*
-gdk_window_new (GdkWindow     *parent,
-               GdkWindowAttr *attributes,
-               gint           attributes_mask)
-{
-  GdkWindow *window;
-  GdkWindowPrivate *private;
-  GdkWindowPrivate *parent_private;
-  GdkVisual *visual;
-  Display *parent_display;
-  Window xparent;
-  Visual *xvisual;
-  XSetWindowAttributes xattributes;
-  long xattributes_mask;
-  XSizeHints size_hints;
-  XWMHints wm_hints;
-  XClassHint *class_hint;
-  int x, y, depth;
-  unsigned int class;
-  char *title;
-  int i;
-  
-  g_return_val_if_fail (attributes != NULL, NULL);
-  
-  if (!parent)
-    parent = (GdkWindow*) &gdk_root_parent;
-  
-  parent_private = (GdkWindowPrivate*) parent;
-  if (GDK_DRAWABLE_DESTROYED (parent))
-    return NULL;
-  
-  xparent = parent_private->drawable.xwindow;
-  parent_display = parent_private->drawable.xdisplay;
-  
-  private = g_new (GdkWindowPrivate, 1);
-  window = (GdkWindow*) private;
-  
-  private->parent = parent;
-  
-  private->drawable.xdisplay = parent_display;
-  private->drawable.destroyed = FALSE;
   private->mapped = FALSE;
   private->guffaw_gravity = FALSE;
-  private->resize_count = 0;
-  private->drawable.ref_count = 1;
-  xattributes_mask = 0;
-  
-  if (attributes_mask & GDK_WA_X)
-    x = attributes->x;
-  else
-    x = 0;
-  
-  if (attributes_mask & GDK_WA_Y)
-    y = attributes->y;
-  else
-    y = 0;
-  
-  private->x = x;
-  private->y = y;
-  private->drawable.width = (attributes->width > 1) ? (attributes->width) : (1);
-  private->drawable.height = (attributes->height > 1) ? (attributes->height) : (1);
-  private->drawable.window_type = attributes->window_type;
   private->extension_events = FALSE;
   
   private->filters = NULL;
   private->children = NULL;
-  
-  window->user_data = NULL;
-  
-  if (attributes_mask & GDK_WA_VISUAL)
-    visual = attributes->visual;
-  else
-    visual = gdk_visual_get_system ();
-  xvisual = ((GdkVisualPrivate*) visual)->xvisual;
-  
-  xattributes.event_mask = StructureNotifyMask;
-  for (i = 0; i < gdk_nevent_masks; i++)
-    {
-      if (attributes->event_mask & (1 << (i + 1)))
-       xattributes.event_mask |= gdk_event_mask_table[i];
-    }
-  
-  if (xattributes.event_mask)
-    xattributes_mask |= CWEventMask;
-  
-  if (attributes_mask & GDK_WA_NOREDIR)
-    {
-      xattributes.override_redirect =
-       (attributes->override_redirect == FALSE)?False:True;
-      xattributes_mask |= CWOverrideRedirect;
-    } 
-  else
-    xattributes.override_redirect = False;
-  
-  if (parent_private && parent_private->guffaw_gravity)
-    {
-      xattributes.win_gravity = StaticGravity;
-      xattributes_mask |= CWWinGravity;
-    }
-  
-  if (attributes->wclass == GDK_INPUT_OUTPUT)
-    {
-      class = InputOutput;
-      depth = visual->depth;
-      
-      if (attributes_mask & GDK_WA_COLORMAP)
-       private->drawable.colormap = attributes->colormap;
-      else
-       {
-         if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual)
-           private->drawable.colormap = gdk_colormap_get_system ();
-         else
-           private->drawable.colormap = gdk_colormap_new (visual, False);
-       }
-      
-      xattributes.background_pixel = BlackPixel (gdk_display, gdk_screen);
-      xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen);
-      xattributes_mask |= CWBorderPixel | CWBackPixel;
-      
-      switch (private->drawable.window_type)
-       {
-       case GDK_WINDOW_TOPLEVEL:
-         xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
-         xattributes_mask |= CWColormap;
-         
-         xparent = gdk_root_window;
-         break;
-         
-       case GDK_WINDOW_CHILD:
-         xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
-         xattributes_mask |= CWColormap;
-         break;
-         
-       case GDK_WINDOW_DIALOG:
-         xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
-         xattributes_mask |= CWColormap;
-         
-         xparent = gdk_root_window;
-         break;
-         
-       case GDK_WINDOW_TEMP:
-         xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
-         xattributes_mask |= CWColormap;
-         
-         xparent = gdk_root_window;
-         
-         xattributes.save_under = True;
-         xattributes.override_redirect = True;
-         xattributes.cursor = None;
-         xattributes_mask |= CWSaveUnder | CWOverrideRedirect;
-         break;
-       case GDK_WINDOW_ROOT:
-         g_error ("cannot make windows of type GDK_WINDOW_ROOT");
-         break;
-       case GDK_WINDOW_PIXMAP:
-         g_error ("cannot make windows of type GDK_WINDOW_PIXMAP (use gdk_pixmap_new)");
-         break;
-       }
-    }
-  else
-    {
-      depth = 0;
-      class = InputOnly;
-      private->drawable.colormap = NULL;
-    }
-  
-  private->drawable.xwindow = XCreateWindow (private->drawable.xdisplay, xparent,
-                                   x, y, private->drawable.width, private->drawable.height,
-                                   0, depth, class, xvisual,
-                                   xattributes_mask, &xattributes);
-  gdk_window_ref (window);
-  gdk_xid_table_insert (&private->drawable.xwindow, window);
-  
-  if (private->drawable.colormap)
-    gdk_colormap_ref (private->drawable.colormap);
-  
-  gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
-                                 (attributes->cursor) :
-                                 NULL));
-  
-  if (parent_private)
-    parent_private->children = g_list_prepend (parent_private->children, window);
-  
-  switch (private->drawable.window_type)
-    {
-    case GDK_WINDOW_DIALOG:
-      XSetTransientForHint (private->drawable.xdisplay, private->drawable.xwindow, xparent);
-    case GDK_WINDOW_TOPLEVEL:
-    case GDK_WINDOW_TEMP:
-      XSetWMProtocols (private->drawable.xdisplay, private->drawable.xwindow, gdk_wm_window_protocols, 2);
-      break;
-    case GDK_WINDOW_CHILD:
-      if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
-         (private->drawable.colormap != gdk_colormap_get_system ()) &&
-         (private->drawable.colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window))))
-       {
-         GDK_NOTE (MISC, g_message ("adding colormap window\n"));
-         gdk_window_add_colormap_windows (window);
-       }
-      
-      return window;
-    default:
-      
-      return window;
-    }
-  
-  size_hints.flags = PSize;
-  size_hints.width = private->drawable.width;
-  size_hints.height = private->drawable.height;
-  
-  wm_hints.flags = InputHint | StateHint | WindowGroupHint;
-  wm_hints.window_group = gdk_leader_window;
-  wm_hints.input = True;
-  wm_hints.initial_state = NormalState;
-  
-  /* FIXME: Is there any point in doing this? Do any WM's pay
-   * attention to PSize, and even if they do, is this the
-   * correct value???
-   */
-  XSetWMNormalHints (private->drawable.xdisplay, private->drawable.xwindow, &size_hints);
-  
-  XSetWMHints (private->drawable.xdisplay, private->drawable.xwindow, &wm_hints);
-  
-  if (!wm_client_leader_atom)
-    wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE);
-  
-  XChangeProperty (private->drawable.xdisplay, private->drawable.xwindow,
-                  wm_client_leader_atom,
-                  XA_WINDOW, 32, PropModeReplace,
-                  (guchar*) &gdk_leader_window, 1);
-  
-  if (attributes_mask & GDK_WA_TITLE)
-    title = attributes->title;
-  else
-    title = g_get_prgname ();
-  
-  XmbSetWMProperties (private->drawable.xdisplay, private->drawable.xwindow,
-                      title, title,
-                      NULL, 0,
-                      NULL, NULL, NULL);
-  
-  if (attributes_mask & GDK_WA_WMCLASS)
-    {
-      class_hint = XAllocClassHint ();
-      class_hint->res_name = attributes->wmclass_name;
-      class_hint->res_class = attributes->wmclass_class;
-      XSetClassHint (private->drawable.xdisplay, private->drawable.xwindow, class_hint);
-      XFree (class_hint);
-    }
-  
-  
-  return window;
-}
-
-GdkWindow *
-gdk_window_foreign_new (guint32 anid)
-{
-  GdkWindow *window;
-  GdkWindowPrivate *private;
-  GdkWindowPrivate *parent_private;
-  XWindowAttributes attrs;
-  Window root, parent;
-  Window *children = NULL;
-  guint nchildren;
-  gboolean result;
-
-  gdk_error_trap_push ();
-  result = XGetWindowAttributes (gdk_display, anid, &attrs);
-  if (gdk_error_trap_pop () || !result)
-    return NULL;
-
-  /* FIXME: This is pretty expensive. Maybe the caller should supply
-   *        the parent */
-  gdk_error_trap_push ();
-  result = XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren);
-  if (gdk_error_trap_pop () || !result)
-    return NULL;
-  
-  private = g_new (GdkWindowPrivate, 1);
-  window = (GdkWindow*) private;
-  
-  if (children)
-    XFree (children);
-  private->parent = gdk_xid_table_lookup (parent);
-  
-  parent_private = (GdkWindowPrivate *)private->parent;
-  
-  if (parent_private)
-    parent_private->children = g_list_prepend (parent_private->children, window);
-  
-  private->drawable.xwindow = anid;
-  private->drawable.xdisplay = gdk_display;
-  private->x = attrs.x;
-  private->y = attrs.y;
-  private->drawable.width = attrs.width;
-  private->drawable.height = attrs.height;
-  private->resize_count = 0;
-  private->drawable.ref_count = 1;
-  private->drawable.window_type = GDK_WINDOW_FOREIGN;
-  private->drawable.destroyed = FALSE;
-  private->mapped = (attrs.map_state != IsUnmapped);
-  private->guffaw_gravity = FALSE;
-  private->extension_events = 0;
-  
-  private->drawable.colormap = NULL;
-  
-  private->filters = NULL;
-  private->children = NULL;
-  
-  window->user_data = NULL;
-  
-  gdk_window_ref (window);
-  gdk_xid_table_insert (&private->drawable.xwindow, window);
-  
-  return window;
-}
-
-/* Call this function when you want a window and all its children to
- * disappear.  When xdestroy is true, a request to destroy the XWindow
- * is sent out.  When it is false, it is assumed that the XWindow has
- * been or will be destroyed by destroying some ancestor of this
- * window.
- */
-static void
-gdk_window_internal_destroy (GdkWindow *window,
-                            gboolean   xdestroy,
-                            gboolean   our_destroy)
-{
-  GdkWindowPrivate *private;
-  GdkWindowPrivate *temp_private;
-  GdkWindow *temp_window;
-  GList *children;
-  GList *tmp;
-  
-  g_return_if_fail (window != NULL);
-  
-  private = (GdkWindowPrivate*) window;
-  
-  switch (private->drawable.window_type)
-    {
-    case GDK_WINDOW_TOPLEVEL:
-    case GDK_WINDOW_CHILD:
-    case GDK_WINDOW_DIALOG:
-    case GDK_WINDOW_TEMP:
-    case GDK_WINDOW_FOREIGN:
-      if (!private->drawable.destroyed)
-       {
-         if (private->parent)
-           {
-             GdkWindowPrivate *parent_private = (GdkWindowPrivate *)private->parent;
-             if (parent_private->children)
-               parent_private->children = g_list_remove (parent_private->children, window);
-           }
-         
-         if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_FOREIGN)
-           {
-             children = tmp = private->children;
-             private->children = NULL;
-             
-             while (tmp)
-               {
-                 temp_window = tmp->data;
-                 tmp = tmp->next;
-                 
-                 temp_private = (GdkWindowPrivate*) temp_window;
-                 if (temp_private)
-                   gdk_window_internal_destroy (temp_window, FALSE,
-                                                our_destroy);
-               }
-             
-             g_list_free (children);
-           }
-         
-         if (private->extension_events != 0)
-           gdk_input_window_destroy (window);
-         
-         if (private->filters)
-           {
-             tmp = private->filters;
-             
-             while (tmp)
-               {
-                 g_free (tmp->data);
-                 tmp = tmp->next;
-               }
-             
-             g_list_free (private->filters);
-             private->filters = NULL;
-           }
-         
-         if (private->drawable.window_type == GDK_WINDOW_FOREIGN)
-           {
-             if (our_destroy && (private->parent != NULL))
-               {
-                 /* It's somebody elses window, but in our heirarchy,
-                  * so reparent it to the root window, and then send
-                  * it a delete event, as if we were a WM
-                  */
-                 XClientMessageEvent xevent;
-
-                 gdk_error_trap_push ();
-                 gdk_window_hide (window);
-                 gdk_window_reparent (window, NULL, 0, 0);
-                 
-                 xevent.type = ClientMessage;
-                 xevent.window = private->drawable.xwindow;
-                 xevent.message_type = gdk_wm_protocols;
-                 xevent.format = 32;
-                 xevent.data.l[0] = gdk_wm_delete_window;
-                 xevent.data.l[1] = CurrentTime;
-
-                 XSendEvent (private->drawable.xdisplay, private->drawable.xwindow,
-                             False, 0, (XEvent *)&xevent);
-                 gdk_flush ();
-                 gdk_error_trap_pop ();
-               }
-           }
-         else if (xdestroy)
-           XDestroyWindow (private->drawable.xdisplay, private->drawable.xwindow);
-         
-         if (private->drawable.colormap)
-           gdk_colormap_unref (private->drawable.colormap);
-         
-         private->mapped = FALSE;
-         private->drawable.destroyed = TRUE;
-       }
-      break;
-      
-    case GDK_WINDOW_ROOT:
-      g_error ("attempted to destroy root window");
-      break;
-      
-    case GDK_WINDOW_PIXMAP:
-      g_error ("called gdk_window_destroy on a pixmap (use gdk_pixmap_unref)");
-      break;
-    }
-}
-
-/* Like internal_destroy, but also destroys the reference created by
-   gdk_window_new. */
-
-void
-gdk_window_destroy (GdkWindow *window)
-{
-  gdk_window_internal_destroy (window, TRUE, TRUE);
-  gdk_window_unref (window);
-}
-
-/* This function is called when the XWindow is really gone.  */
-
-void
-gdk_window_destroy_notify (GdkWindow *window)
-{
-  g_return_if_fail (window != NULL);
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      if (GDK_DRAWABLE_TYPE(window) != GDK_WINDOW_FOREIGN)
-       g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_DRAWABLE_XID (window));
 
-      gdk_window_internal_destroy (window, FALSE, FALSE);
-    }
-  
-  gdk_xid_table_remove (GDK_DRAWABLE_XID (window));
-  gdk_window_unref (window);
-}
-
-GdkWindow*
-gdk_window_ref (GdkWindow *window)
-{
-  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
-  g_return_val_if_fail (window != NULL, NULL);
-  
-  private->drawable.ref_count += 1;
   return window;
 }
 
 void
-gdk_window_unref (GdkWindow *window)
-{
-  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
-  g_return_if_fail (window != NULL);
-  
-  private->drawable.ref_count -= 1;
-  if (private->drawable.ref_count == 0)
-    {
-      if (!private->drawable.destroyed)
-       {
-         if (private->drawable.window_type == GDK_WINDOW_FOREIGN)
-           gdk_xid_table_remove (private->drawable.xwindow);
-         else
-           g_warning ("losing last reference to undestroyed window\n");
-       }
-      g_dataset_destroy (window);
-      g_free (window);
-    }
-}
-
-void
-gdk_window_show (GdkWindow *window)
-{
-  GdkWindowPrivate *private;
-  
-  g_return_if_fail (window != NULL);
-  
-  private = (GdkWindowPrivate*) window;
-  if (!private->drawable.destroyed)
-    {
-      private->mapped = TRUE;
-      XRaiseWindow (private->drawable.xdisplay, private->drawable.xwindow);
-      XMapWindow (private->drawable.xdisplay, private->drawable.xwindow);
-    }
-}
-
-void
-gdk_window_hide (GdkWindow *window)
-{
-  GdkWindowPrivate *private;
-  
-  g_return_if_fail (window != NULL);
-  
-  private = (GdkWindowPrivate*) window;
-  if (!private->drawable.destroyed)
-    {
-      private->mapped = FALSE;
-      XUnmapWindow (private->drawable.xdisplay, private->drawable.xwindow);
-    }
-}
-
-void
-gdk_window_withdraw (GdkWindow *window)
+gdk_window_set_user_data (GdkWindow *window,
+                         gpointer   user_data)
 {
-  GdkWindowPrivate *private;
-  
   g_return_if_fail (window != NULL);
   
-  private = (GdkWindowPrivate*) window;
-  if (!private->drawable.destroyed)
-    XWithdrawWindow (private->drawable.xdisplay, private->drawable.xwindow, 0);
+  window->user_data = user_data;
 }
 
 void
-gdk_window_move (GdkWindow *window,
-                gint       x,
-                gint       y)
+gdk_window_get_user_data (GdkWindow *window,
+                         gpointer  *data)
 {
-  GdkWindowPrivate *private;
-  
   g_return_if_fail (window != NULL);
   
-  private = (GdkWindowPrivate*) window;
-  if (!private->drawable.destroyed)
-    {
-      XMoveWindow (private->drawable.xdisplay, private->drawable.xwindow, x, y);
-      
-      if (private->drawable.window_type == GDK_WINDOW_CHILD)
-       {
-         private->x = x;
-         private->y = y;
-       }
-    }
-}
-
-void
-gdk_window_resize (GdkWindow *window,
-                  gint       width,
-                  gint       height)
-{
-  GdkWindowPrivate *private;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (width < 1)
-    width = 1;
-  if (height < 1)
-    height = 1;
-
-  private = (GdkWindowPrivate*) window;
-  
-  if (!private->drawable.destroyed &&
-      ((private->resize_count > 0) ||
-       (private->drawable.width != (guint16) width) ||
-       (private->drawable.height != (guint16) height)))
-    {
-      XResizeWindow (GDK_DRAWABLE_XDISPLAY (private),
-                    GDK_DRAWABLE_XID (private),
-                    width, height);
-      private->resize_count += 1;
-      
-      if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD)
-       {
-         private->drawable.width = width;
-         private->drawable.height = height;
-       }
-    }
-}
-
-void
-gdk_window_move_resize (GdkWindow *window,
-                       gint       x,
-                       gint       y,
-                       gint       width,
-                       gint       height)
-{
-  GdkWindowPrivate *private;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-
-  if (width < 1)
-    width = 1;
-  if (height < 1)
-    height = 1;
-  
-  private = (GdkWindowPrivate*) window;
-
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window),
-                        GDK_DRAWABLE_XID (window),
-                        x, y, width, height);
-      
-      if (private->guffaw_gravity)
-       {
-         GList *tmp_list = private->children;
-         while (tmp_list)
-           {
-             GdkWindowPrivate *child_private = tmp_list->data;
-             
-             child_private->x -= x - private->x;
-             child_private->y -= y - private->y;
-             
-             tmp_list = tmp_list->next;
-           }
-       }
-      
-      if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD)
-       {
-         private->x = x;
-         private->y = y;
-         private->drawable.width = width;
-         private->drawable.height = height;
-       }
-    }
-}
-
-void
-gdk_window_reparent (GdkWindow *window,
-                    GdkWindow *new_parent,
-                    gint       x,
-                    gint       y)
-{
-  GdkWindowPrivate *window_private;
-  GdkWindowPrivate *parent_private;
-  GdkWindowPrivate *old_parent_private;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  g_return_if_fail (new_parent != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (new_parent));
-  
-  if (!new_parent)
-    new_parent = (GdkWindow*) &gdk_root_parent;
-  
-  window_private = (GdkWindowPrivate*) window;
-  old_parent_private = (GdkWindowPrivate*)window_private->parent;
-  parent_private = (GdkWindowPrivate*) new_parent;
-  
-  if (!GDK_DRAWABLE_DESTROYED (window) && !GDK_DRAWABLE_DESTROYED (new_parent))
-    XReparentWindow (GDK_DRAWABLE_XDISPLAY (window),
-                    GDK_DRAWABLE_XID (window),
-                    GDK_DRAWABLE_XID (new_parent),
-                    x, y);
-  
-  window_private->parent = new_parent;
-  
-  if (old_parent_private)
-    old_parent_private->children = g_list_remove (old_parent_private->children, window);
-  
-  if ((old_parent_private &&
-       (!old_parent_private->guffaw_gravity != !parent_private->guffaw_gravity)) ||
-      (!old_parent_private && parent_private->guffaw_gravity))
-    gdk_window_set_static_win_gravity (window, parent_private->guffaw_gravity);
-  
-  parent_private->children = g_list_prepend (parent_private->children, window);
-}
-
-void
-gdk_window_clear (GdkWindow *window)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XClearWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window));
-}
-
-void
-gdk_window_clear_area (GdkWindow *window,
-                      gint       x,
-                      gint       y,
-                      gint       width,
-                      gint       height)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XClearArea (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window),
-               x, y, width, height, False);
-}
-
-void
-gdk_window_clear_area_e (GdkWindow *window,
-                        gint       x,
-                        gint       y,
-                        gint       width,
-                        gint       height)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XClearArea (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window),
-               x, y, width, height, True);
-}
-
-void
-gdk_window_raise (GdkWindow *window)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XRaiseWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window));
-}
-
-void
-gdk_window_lower (GdkWindow *window)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XLowerWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window));
-}
-
-void
-gdk_window_set_user_data (GdkWindow *window,
-                         gpointer   user_data)
-{
-  g_return_if_fail (window != NULL);
-  
-  window->user_data = user_data;
-}
-
-void
-gdk_window_set_hints (GdkWindow *window,
-                     gint       x,
-                     gint       y,
-                     gint       min_width,
-                     gint       min_height,
-                     gint       max_width,
-                     gint       max_height,
-                     gint       flags)
-{
-  XSizeHints size_hints;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
-  
-  size_hints.flags = 0;
-  
-  if (flags & GDK_HINT_POS)
-    {
-      size_hints.flags |= PPosition;
-      size_hints.x = x;
-      size_hints.y = y;
-    }
-  
-  if (flags & GDK_HINT_MIN_SIZE)
-    {
-      size_hints.flags |= PMinSize;
-      size_hints.min_width = min_width;
-      size_hints.min_height = min_height;
-    }
-  
-  if (flags & GDK_HINT_MAX_SIZE)
-    {
-      size_hints.flags |= PMaxSize;
-      size_hints.max_width = max_width;
-      size_hints.max_height = max_height;
-    }
-  
-  /* FIXME: Would it be better to delete this property of
-   *        flags == 0? It would save space on the server
-   */
-  XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window),
-                    GDK_DRAWABLE_XID (window),
-                    &size_hints);
-}
-
-void 
-gdk_window_set_geometry_hints (GdkWindow      *window,
-                              GdkGeometry    *geometry,
-                              GdkWindowHints  geom_mask)
-{
-  XSizeHints size_hints;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
-  
-  size_hints.flags = 0;
-  
-  if (geom_mask & GDK_HINT_POS)
-    {
-      size_hints.flags |= PPosition;
-      /* We need to initialize the following obsolete fields because KWM 
-       * apparently uses these fields if they are non-zero.
-       * #@#!#!$!.
-       */
-      size_hints.x = 0;
-      size_hints.y = 0;
-    }
-  
-  if (geom_mask & GDK_HINT_MIN_SIZE)
-    {
-      size_hints.flags |= PMinSize;
-      size_hints.min_width = geometry->min_width;
-      size_hints.min_height = geometry->min_height;
-    }
-  
-  if (geom_mask & GDK_HINT_MAX_SIZE)
-    {
-      size_hints.flags |= PMaxSize;
-      size_hints.max_width = MAX (geometry->max_width, 1);
-      size_hints.max_height = MAX (geometry->max_height, 1);
-    }
-  
-  if (geom_mask & GDK_HINT_BASE_SIZE)
-    {
-      size_hints.flags |= PBaseSize;
-      size_hints.base_width = geometry->base_width;
-      size_hints.base_height = geometry->base_height;
-    }
-  
-  if (geom_mask & GDK_HINT_RESIZE_INC)
-    {
-      size_hints.flags |= PResizeInc;
-      size_hints.width_inc = geometry->width_inc;
-      size_hints.height_inc = geometry->height_inc;
-    }
-  
-  if (geom_mask & GDK_HINT_ASPECT)
-    {
-      size_hints.flags |= PAspect;
-      if (geometry->min_aspect <= 1)
-       {
-         size_hints.min_aspect.x = 65536 * geometry->min_aspect;
-         size_hints.min_aspect.y = 65536;
-       }
-      else
-       {
-         size_hints.min_aspect.x = 65536;
-         size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
-       }
-      if (geometry->max_aspect <= 1)
-       {
-         size_hints.max_aspect.x = 65536 * geometry->max_aspect;
-         size_hints.max_aspect.y = 65536;
-       }
-      else
-       {
-         size_hints.max_aspect.x = 65536;
-         size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
-       }
-    }
-
-  /* FIXME: Would it be better to delete this property of
-   *        geom_mask == 0? It would save space on the server
-   */
-  XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window),
-                    GDK_DRAWABLE_XID (window),
-                    &size_hints);
-}
-
-void
-gdk_window_set_title (GdkWindow   *window,
-                     const gchar *title)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XmbSetWMProperties (GDK_DRAWABLE_XDISPLAY (window),
-                       GDK_DRAWABLE_XID (window),
-                       title, title, NULL, 0, NULL, NULL, NULL);
-}
-
-void          
-gdk_window_set_role (GdkWindow   *window,
-                    const gchar *role)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      if (role)
-       XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window),
-                        gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING,
-                        8, PropModeReplace, role, strlen (role));
-      else
-       XDeleteProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window),
-                        gdk_atom_intern ("WM_WINDOW_ROLE", FALSE));
-    }
-}
-
-void          
-gdk_window_set_transient_for (GdkWindow *window, 
-                             GdkWindow *parent)
-{
-  GdkWindowPrivate *private;
-  GdkWindowPrivate *parent_private;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  private = (GdkWindowPrivate*) window;
-  parent_private = (GdkWindowPrivate*) parent;
-  
-  if (!GDK_DRAWABLE_DESTROYED (window) && !GDK_DRAWABLE_DESTROYED (parent))
-    XSetTransientForHint (GDK_DRAWABLE_XDISPLAY (window), 
-                         GDK_DRAWABLE_XID (window),
-                         GDK_DRAWABLE_XID (parent));
-}
-
-void
-gdk_window_set_background (GdkWindow *window,
-                          GdkColor  *color)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XSetWindowBackground (GDK_DRAWABLE_XDISPLAY (window),
-                         GDK_DRAWABLE_XID (window), color->pixel);
-}
-
-void
-gdk_window_set_back_pixmap (GdkWindow *window,
-                           GdkPixmap *pixmap,
-                           gint       parent_relative)
-{
-  Pixmap xpixmap;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (pixmap)
-    xpixmap = GDK_DRAWABLE_XID (pixmap);
-  else
-    xpixmap = None;
-  
-  if (parent_relative)
-    xpixmap = ParentRelative;
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window),
-                               GDK_DRAWABLE_XID (window), xpixmap);
-}
-
-void
-gdk_window_set_cursor (GdkWindow *window,
-                      GdkCursor *cursor)
-{
-  GdkCursorPrivate *cursor_private;
-  Cursor xcursor;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  cursor_private = (GdkCursorPrivate*) cursor;
-  
-  if (!cursor)
-    xcursor = None;
-  else
-    xcursor = cursor_private->xcursor;
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    XDefineCursor (GDK_DRAWABLE_XDISPLAY (window),
-                  GDK_DRAWABLE_XID (window),
-                  xcursor);
-}
-
-void
-gdk_window_get_user_data (GdkWindow *window,
-                         gpointer  *data)
-{
-  g_return_if_fail (window != NULL);
-  
-  *data = window->user_data;
-}
-
-void
-gdk_window_get_geometry (GdkWindow *window,
-                        gint      *x,
-                        gint      *y,
-                        gint      *width,
-                        gint      *height,
-                        gint      *depth)
-{
-  Window root;
-  gint tx;
-  gint ty;
-  guint twidth;
-  guint theight;
-  guint tborder_width;
-  guint tdepth;
-  
-  g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
-  
-  if (!window)
-    window = (GdkWindow *) &gdk_root_parent;
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      XGetGeometry (GDK_DRAWABLE_XDISPLAY (window),
-                   GDK_DRAWABLE_XID (window),
-                   &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
-      
-      if (x)
-       *x = tx;
-      if (y)
-       *y = ty;
-      if (width)
-       *width = twidth;
-      if (height)
-       *height = theight;
-      if (depth)
-       *depth = tdepth;
-    }
+  *data = window->user_data;
 }
 
 void
 gdk_window_get_position (GdkWindow *window,
                         gint      *x,
                         gint      *y)
-{
-  GdkWindowPrivate *window_private;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  window_private = (GdkWindowPrivate*) window;
-  
-  if (x)
-    *x = window_private->x;
-  if (y)
-    *y = window_private->y;
-}
-
-gint
-gdk_window_get_origin (GdkWindow *window,
-                      gint      *x,
-                      gint      *y)
-{
-  gint return_val;
-  Window child;
-  gint tx = 0;
-  gint ty = 0;
-  
-  g_return_val_if_fail (window != NULL, 0);
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      return_val = XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window),
-                                         GDK_DRAWABLE_XID (window),
-                                         gdk_root_window,
-                                         0, 0, &tx, &ty,
-                                         &child);
-      
-    }
-  else
-    return_val = 0;
-  
-  if (x)
-    *x = tx;
-  if (y)
-    *y = ty;
-  
-  return return_val;
-}
-
-gboolean
-gdk_window_get_deskrelative_origin (GdkWindow *window,
-                                   gint      *x,
-                                   gint      *y)
-{
-  gboolean return_val = FALSE;
-  gint num_children, format_return;
-  Window win, *child, parent, root;
-  gint tx = 0;
-  gint ty = 0;
-  Atom type_return;
-  static Atom atom = 0;
-  gulong number_return, bytes_after_return;
-  guchar *data_return;
-  
-  g_return_val_if_fail (window != NULL, 0);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      if (!atom)
-       atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE);
-      win = GDK_DRAWABLE_XID (window);
-      
-      while (XQueryTree (GDK_DRAWABLE_XDISPLAY (window), win, &root, &parent,
-                        &child, (unsigned int *)&num_children))
-       {
-         if ((child) && (num_children > 0))
-           XFree (child);
-         
-         if (!parent)
-           break;
-         else
-           win = parent;
-         
-         if (win == root)
-           break;
-         
-         data_return = NULL;
-         XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (window), win, atom, 0, 0,
-                             False, XA_CARDINAL, &type_return, &format_return,
-                             &number_return, &bytes_after_return, &data_return);
-         if (type_return == XA_CARDINAL)
-           {
-             XFree (data_return);
-              break;
-           }
-       }
-      
-      return_val = XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window),
-                                         GDK_DRAWABLE_XID (window),
-                                         win,
-                                         0, 0, &tx, &ty,
-                                         &root);
-      if (x)
-       *x = tx;
-      if (y)
-       *y = ty;
-    }
-  
-  
-  return return_val;
-}
-
-void
-gdk_window_get_root_origin (GdkWindow *window,
-                           gint      *x,
-                           gint      *y)
-{
-  GdkWindowPrivate *private;
-  Window xwindow;
-  Window xparent;
-  Window root;
-  Window *children;
-  unsigned int nchildren;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  private = (GdkWindowPrivate*) window;
-  if (x)
-    *x = 0;
-  if (y)
-    *y = 0;
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
-  
-  while (private->parent && ((GdkWindowPrivate*) private->parent)->parent)
-    private = (GdkWindowPrivate*) private->parent;
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
-  
-  xparent = GDK_DRAWABLE_XID (window);
-  do
-    {
-      xwindow = xparent;
-      if (!XQueryTree (GDK_DRAWABLE_XDISPLAY (window), xwindow,
-                      &root, &xparent,
-                      &children, &nchildren))
-       return;
-      
-      if (children)
-       XFree (children);
-    }
-  while (xparent != root);
-  
-  if (xparent == root)
-    {
-      unsigned int ww, wh, wb, wd;
-      int wx, wy;
-      
-      if (XGetGeometry (GDK_DRAWABLE_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd))
-       {
-         if (x)
-           *x = wx;
-         if (y)
-           *y = wy;
-       }
-    }
-}
-
-GdkWindow*
-gdk_window_get_pointer (GdkWindow       *window,
-                       gint            *x,
-                       gint            *y,
-                       GdkModifierType *mask)
-{
-  GdkWindow *return_val;
-  Window root;
-  Window child;
-  int rootx, rooty;
-  int winx = 0;
-  int winy = 0;
-  unsigned int xmask = 0;
-
-  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
-  
-  if (!window)
-    window = (GdkWindow*) &gdk_root_parent;
-  
-  return_val = NULL;
-  if (!GDK_DRAWABLE_DESTROYED (window) &&
-      XQueryPointer (GDK_DRAWABLE_XDISPLAY (window),
-                    GDK_DRAWABLE_XID (window),
-                    &root, &child, &rootx, &rooty, &winx, &winy, &xmask))
-    {
-      if (child)
-       return_val = gdk_window_lookup (child);
-    }
-  
-  if (x)
-    *x = winx;
-  if (y)
-    *y = winy;
-  if (mask)
-    *mask = xmask;
-  
-  return return_val;
-}
-
-GdkWindow*
-gdk_window_at_pointer (gint *win_x,
-                      gint *win_y)
-{
-  GdkWindowPrivate *private;
-  GdkWindow *window;
-  Window root;
-  Window xwindow;
-  Window xwindow_last = 0;
-  int rootx = -1, rooty = -1;
-  int winx, winy;
-  unsigned int xmask;
-  
-  private = &gdk_root_parent;
-  
-  xwindow = private->drawable.xwindow;
-  
-  XGrabServer (private->drawable.xdisplay);
-  while (xwindow)
-    {
-      xwindow_last = xwindow;
-      XQueryPointer (private->drawable.xdisplay,
-                    xwindow,
-                    &root, &xwindow,
-                    &rootx, &rooty,
-                    &winx, &winy,
-                    &xmask);
-    }
-  XUngrabServer (private->drawable.xdisplay);
-  
-  window = gdk_window_lookup (xwindow_last);
-  
-  if (win_x)
-    *win_x = window ? winx : -1;
-  if (win_y)
-    *win_y = window ? winy : -1;
-  
-  return window;
-}
-
-GdkWindow*
-gdk_window_get_parent (GdkWindow *window)
-{
-  g_return_val_if_fail (window != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-  
-  return ((GdkWindowPrivate*) window)->parent;
-}
-
-GdkWindow*
-gdk_window_get_toplevel (GdkWindow *window)
-{
-  GdkWindowPrivate *private;
-  
-  g_return_val_if_fail (window != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
-  private = (GdkWindowPrivate *)window;
-  while (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD)
-    private = (GdkWindowPrivate *)private->parent;
-  
-  return (GdkWindow *)window;
-}
-
-GList*
-gdk_window_get_children (GdkWindow *window)
-{
-  GdkWindow *child;
-  GList *children;
-  Window root;
-  Window parent;
-  Window *xchildren;
-  unsigned int nchildren;
-  unsigned int i;
-  
-  g_return_val_if_fail (window != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return NULL;
-  
-  XQueryTree (GDK_DRAWABLE_XDISPLAY (window),
-             GDK_DRAWABLE_XID (window),
-             &root, &parent, &xchildren, &nchildren);
-  
-  children = NULL;
-  
-  if (nchildren > 0)
-    {
-      for (i = 0; i < nchildren; i++)
-       {
-         child = gdk_window_lookup (xchildren[i]);
-          if (child)
-            children = g_list_prepend (children, child);
-       }
-      
-      if (xchildren)
-       XFree (xchildren);
-    }
-  
-  return children;
-}
-
-GdkEventMask  
-gdk_window_get_events (GdkWindow *window)
-{
-  XWindowAttributes attrs;
-  GdkEventMask event_mask;
-  int i;
-  
-  g_return_val_if_fail (window != NULL, 0);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return 0;
-  else
-    {
-      XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (window),
-                           GDK_DRAWABLE_XID (window), 
-                           &attrs);
-      
-      event_mask = 0;
-      for (i = 0; i < gdk_nevent_masks; i++)
-       {
-         if (attrs.your_event_mask & gdk_event_mask_table[i])
-           event_mask |= 1 << (i + 1);
-       }
-  
-      return event_mask;
-    }
-}
-
-void          
-gdk_window_set_events (GdkWindow       *window,
-                      GdkEventMask     event_mask)
-{
-  long xevent_mask;
-  int i;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      xevent_mask = StructureNotifyMask;
-      for (i = 0; i < gdk_nevent_masks; i++)
-       {
-         if (event_mask & (1 << (i + 1)))
-           xevent_mask |= gdk_event_mask_table[i];
-       }
-      
-      XSelectInput (GDK_DRAWABLE_XDISPLAY (window),
-                   GDK_DRAWABLE_XID (window),
-                   xevent_mask);
-    }
-}
-
-void
-gdk_window_add_colormap_windows (GdkWindow *window)
-{
-  GdkWindow *toplevel;
-  Window *old_windows;
-  Window *new_windows;
-  int i, count;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  toplevel = gdk_window_get_toplevel (window);
-  if (GDK_DRAWABLE_DESTROYED (toplevel))
-    return;
-  
-  old_windows = NULL;
-  if (!XGetWMColormapWindows (GDK_DRAWABLE_XDISPLAY (toplevel),
-                             GDK_DRAWABLE_XID (toplevel),
-                             &old_windows, &count))
-    {
-      count = 0;
-    }
-  
-  for (i = 0; i < count; i++)
-    if (old_windows[i] == GDK_DRAWABLE_XID (window))
-      {
-       XFree (old_windows);
-       return;
-      }
-  
-  new_windows = g_new (Window, count + 1);
+{
+  GdkWindowPrivate *window_private;
   
-  for (i = 0; i < count; i++)
-    new_windows[i] = old_windows[i];
-  new_windows[count] = GDK_DRAWABLE_XID (window);
+  g_return_if_fail (window != NULL);
+  g_return_if_fail (GDK_IS_WINDOW (window));
   
-  XSetWMColormapWindows (GDK_DRAWABLE_XDISPLAY (toplevel),
-                        GDK_DRAWABLE_XID (toplevel),
-                        new_windows, count + 1);
+  window_private = (GdkWindowPrivate*) window;
   
-  g_free (new_windows);
-  if (old_windows)
-    XFree (old_windows);
+  if (x)
+    *x = window_private->x;
+  if (y)
+    *y = window_private->y;
 }
 
-static gboolean
-gdk_window_have_shape_ext (void)
+GdkWindow*
+gdk_window_get_parent (GdkWindow *window)
 {
-  enum { UNKNOWN, NO, YES };
-  static gint have_shape = UNKNOWN;
-  
-  if (have_shape == UNKNOWN)
-    {
-      int ignore;
-      if (XQueryExtension (gdk_display, "SHAPE", &ignore, &ignore, &ignore))
-       have_shape = YES;
-      else
-       have_shape = NO;
-    }
+  g_return_val_if_fail (window != NULL, NULL);
+  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
   
-  return (have_shape == YES);
+  return ((GdkWindowPrivate*) window)->parent;
 }
 
-/*
- * This needs the X11 shape extension.
- * If not available, shaped windows will look
- * ugly, but programs still work.    Stefan Wille
- */
-void
-gdk_window_shape_combine_mask (GdkWindow *window,
-                              GdkBitmap *mask,
-                              gint x, gint y)
+GdkWindow*
+gdk_window_get_toplevel (GdkWindow *window)
 {
-  Pixmap pixmap;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
+  GdkWindowPrivate *private;
   
-#ifdef HAVE_SHAPE_EXT
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
+  g_return_val_if_fail (window != NULL, NULL);
+  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+
+  private = (GdkWindowPrivate *)window;
+  while (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD)
+    private = (GdkWindowPrivate *)private->parent;
   
-  if (gdk_window_have_shape_ext ())
-    {
-      if (mask)
-       {
-         pixmap = GDK_DRAWABLE_XID (mask);
-       }
-      else
-       {
-         x = 0;
-         y = 0;
-         pixmap = None;
-       }
-      
-      XShapeCombineMask (GDK_DRAWABLE_XDISPLAY (window),
-                        GDK_DRAWABLE_XID (window),
-                        ShapeBounding,
-                        x, y,
-                        pixmap,
-                        ShapeSet);
-    }
-#endif /* HAVE_SHAPE_EXT */
+  return (GdkWindow *)window;
 }
 
 void          
@@ -1843,208 +199,13 @@ gdk_window_remove_filter (GdkWindow     *window,
     }
 }
 
-void
-gdk_window_set_override_redirect (GdkWindow *window,
-                                 gboolean override_redirect)
-{
-  XSetWindowAttributes attr;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    {
-      attr.override_redirect = (override_redirect == FALSE)?False:True;
-      XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window),
-                              GDK_DRAWABLE_XID (window),
-                              CWOverrideRedirect,
-                              &attr);
-    }
-}
-
-void          
-gdk_window_set_icon (GdkWindow *window, 
-                    GdkWindow *icon_window,
-                    GdkPixmap *pixmap,
-                    GdkBitmap *mask)
-{
-  XWMHints *wm_hints;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
-
-  wm_hints = XGetWMHints (GDK_DRAWABLE_XDISPLAY (window),
-                         GDK_DRAWABLE_XID (window));
-  if (!wm_hints)
-    wm_hints = XAllocWMHints ();
-
-  if (icon_window != NULL)
-    {
-      wm_hints->flags |= IconWindowHint;
-      wm_hints->icon_window = GDK_DRAWABLE_XID (icon_window);
-    }
-  
-  if (pixmap != NULL)
-    {
-      wm_hints->flags |= IconPixmapHint;
-      wm_hints->icon_pixmap = GDK_DRAWABLE_XID (pixmap);
-    }
-  
-  if (mask != NULL)
-    {
-      wm_hints->flags |= IconMaskHint;
-      wm_hints->icon_mask = GDK_DRAWABLE_XID (mask);
-    }
-
-  XSetWMHints (GDK_DRAWABLE_XDISPLAY (window),
-              GDK_DRAWABLE_XID (window), wm_hints);
-  XFree (wm_hints);
-}
-
-void          
-gdk_window_set_icon_name (GdkWindow *window, 
-                         gchar *    name)
-{
-  XTextProperty property;
-  gint res;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
-  
-  res = XmbTextListToTextProperty (GDK_DRAWABLE_XDISPLAY (window),
-                                  &name, 1, XStdICCTextStyle,
-                                          &property);
-  if (res < 0)
-    {
-      g_warning ("Error converting icon name to text property: %d\n", res);
-      return;
-    }
-  
-  XSetWMIconName (GDK_DRAWABLE_XDISPLAY (window),
-                 GDK_DRAWABLE_XID (window),
-                 &property);
-  
-  if (property.value)
-    XFree (property.value);
-}
-
-void          
-gdk_window_set_group (GdkWindow *window, 
-                     GdkWindow *leader)
-{
-  XWMHints *wm_hints;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  g_return_if_fail (leader != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (leader));
-
-  if (GDK_DRAWABLE_DESTROYED (window) || GDK_DRAWABLE_DESTROYED (leader))
-    return;
-  
-  wm_hints = XGetWMHints (GDK_DRAWABLE_XDISPLAY (window),
-                         GDK_DRAWABLE_XID (window));
-  if (!wm_hints)
-    wm_hints = XAllocWMHints ();
-
-  wm_hints->flags |= WindowGroupHint;
-  wm_hints->window_group = GDK_DRAWABLE_XID (leader);
-
-  XSetWMHints (GDK_DRAWABLE_XDISPLAY (window),
-              GDK_DRAWABLE_XID (window), wm_hints);
-  XFree (wm_hints);
-}
-
-static void
-gdk_window_set_mwm_hints (GdkWindow *window,
-                         MotifWmHints *new_hints)
-{
-  static Atom hints_atom = None;
-  MotifWmHints *hints;
-  Atom type;
-  gint format;
-  gulong nitems;
-  gulong bytes_after;
-  
-  if (GDK_DRAWABLE_DESTROYED (window))
-    return;
-  
-  if (!hints_atom)
-    hints_atom = XInternAtom (GDK_DRAWABLE_XDISPLAY (window), 
-                             _XA_MOTIF_WM_HINTS, FALSE);
-  
-  XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window),
-                     hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
-                     False, AnyPropertyType, &type, &format, &nitems,
-                     &bytes_after, (guchar **)&hints);
-  
-  if (type == None)
-    hints = new_hints;
-  else
-    {
-      if (new_hints->flags & MWM_HINTS_FUNCTIONS)
-       {
-         hints->flags |= MWM_HINTS_FUNCTIONS;
-         hints->functions = new_hints->functions;
-       }
-      if (new_hints->flags & MWM_HINTS_DECORATIONS)
-       {
-         hints->flags |= MWM_HINTS_DECORATIONS;
-         hints->decorations = new_hints->decorations;
-       }
-    }
-  
-  XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window),
-                  hints_atom, hints_atom, 32, PropModeReplace,
-                  (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
-  
-  if (hints != new_hints)
-    XFree (hints);
-}
-
-void
-gdk_window_set_decorations (GdkWindow      *window,
-                           GdkWMDecoration decorations)
-{
-  MotifWmHints hints;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  hints.flags = MWM_HINTS_DECORATIONS;
-  hints.decorations = decorations;
-  
-  gdk_window_set_mwm_hints (window, &hints);
-}
-
-void
-gdk_window_set_functions (GdkWindow    *window,
-                         GdkWMFunction functions)
-{
-  MotifWmHints hints;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  hints.flags = MWM_HINTS_FUNCTIONS;
-  hints.functions = functions;
-  
-  gdk_window_set_mwm_hints (window, &hints);
-}
-
 GList *
 gdk_window_get_toplevels (void)
 {
   GList *new_list = NULL;
   GList *tmp_list;
   
-  tmp_list = gdk_root_parent.children;
+  tmp_list = ((GdkWindowPrivate *)gdk_parent_root)->children;
   while (tmp_list)
     {
       new_list = g_list_prepend (new_list, tmp_list->data);
@@ -2054,347 +215,6 @@ gdk_window_get_toplevels (void)
   return new_list;
 }
 
-/* 
- * propagate the shapes from all child windows of a GDK window to the parent 
- * window. Shamelessly ripped from Enlightenment's code
- * 
- * - Raster
- */
-
-struct _gdk_span
-{
-  gint                start;
-  gint                end;
-  struct _gdk_span    *next;
-};
-
-static void
-gdk_add_to_span (struct _gdk_span **s,
-                gint               x,
-                gint               xx)
-{
-  struct _gdk_span *ptr1, *ptr2, *noo, *ss;
-  gchar             spanning;
-  
-  ptr2 = NULL;
-  ptr1 = *s;
-  spanning = 0;
-  ss = NULL;
-  /* scan the spans for this line */
-  while (ptr1)
-    {
-      /* -- -> new span */
-      /* == -> existing span */
-      /* ## -> spans intersect */
-      /* if we are in the middle of spanning the span into the line */
-      if (spanning)
-       {
-         /* case: ---- ==== */
-         if (xx < ptr1->start - 1)
-           {
-             /* ends before next span - extend to here */
-             ss->end = xx;
-             return;
-           }
-         /* case: ----##=== */
-         else if (xx <= ptr1->end)
-           {
-             /* crosses into next span - delete next span and append */
-             ss->end = ptr1->end;
-             ss->next = ptr1->next;
-             g_free (ptr1);
-             return;
-           }
-         /* case: ---###--- */
-         else
-           {
-             /* overlaps next span - delete and keep checking */
-             ss->next = ptr1->next;
-             g_free (ptr1);
-             ptr1 = ss;
-           }
-       }
-      /* otherwise havent started spanning it in yet */
-      else
-       {
-         /* case: ---- ==== */
-         if (xx < ptr1->start - 1)
-           {
-             /* insert span here in list */
-             noo = g_malloc (sizeof (struct _gdk_span));
-             
-             if (noo)
-               {
-                 noo->start = x;
-                 noo->end = xx;
-                 noo->next = ptr1;
-                 if (ptr2)
-                   ptr2->next = noo;
-                 else
-                   *s = noo;
-               }
-             return;
-           }
-         /* case: ----##=== */
-         else if ((x < ptr1->start) && (xx <= ptr1->end))
-           {
-             /* expand this span to the left point of the new one */
-             ptr1->start = x;
-             return;
-           }
-         /* case: ===###=== */
-         else if ((x >= ptr1->start) && (xx <= ptr1->end))
-           {
-             /* throw the span away */
-             return;
-           }
-         /* case: ---###--- */
-         else if ((x < ptr1->start) && (xx > ptr1->end))
-           {
-             ss = ptr1;
-             spanning = 1;
-             ptr1->start = x;
-             ptr1->end = xx;
-           }
-         /* case: ===##---- */
-         else if ((x >= ptr1->start) && (x <= ptr1->end + 1) && (xx > ptr1->end))
-           {
-             ss = ptr1;
-             spanning = 1;
-             ptr1->end = xx;
-           }
-         /* case: ==== ---- */
-         /* case handled by next loop iteration - first case */
-       }
-      ptr2 = ptr1;
-      ptr1 = ptr1->next;
-    }
-  /* it started in the middle but spans beyond your current list */
-  if (spanning)
-    {
-      ptr2->end = xx;
-      return;
-    }
-  /* it does not start inside a span or in the middle, so add it to the end */
-  noo = g_malloc (sizeof (struct _gdk_span));
-  
-  if (noo)
-    {
-      noo->start = x;
-      noo->end = xx;
-      if (ptr2)
-       {
-         noo->next = ptr2->next;
-         ptr2->next = noo;
-       }
-      else
-       {
-         noo->next = NULL;
-         *s = noo;
-       }
-    }
-  return;
-}
-
-static void
-gdk_add_rectangles (Display           *disp,
-                   Window             win,
-                   struct _gdk_span **spans,
-                   gint               basew,
-                   gint               baseh,
-                   gint               x,
-                   gint               y)
-{
-  gint a, k;
-  gint x1, y1, x2, y2;
-  gint rn, ord;
-  XRectangle *rl;
-  
-  rl = XShapeGetRectangles (disp, win, ShapeBounding, &rn, &ord);
-  if (rl)
-    {
-      /* go through all clip rects in this window's shape */
-      for (k = 0; k < rn; k++)
-       {
-         /* for each clip rect, add it to each line's spans */
-         x1 = x + rl[k].x;
-         x2 = x + rl[k].x + (rl[k].width - 1);
-         y1 = y + rl[k].y;
-         y2 = y + rl[k].y + (rl[k].height - 1);
-         if (x1 < 0)
-           x1 = 0;
-         if (y1 < 0)
-           y1 = 0;
-         if (x2 >= basew)
-           x2 = basew - 1;
-         if (y2 >= baseh)
-           y2 = baseh - 1;
-         for (a = y1; a <= y2; a++)
-           {
-             if ((x2 - x1) >= 0)
-               gdk_add_to_span (&spans[a], x1, x2);
-           }
-       }
-      XFree (rl);
-    }
-}
-
-static void
-gdk_propagate_shapes (Display *disp,
-                     Window   win,
-                     gboolean merge)
-{
-  Window              rt, par, *list = NULL;
-  gint                i, j, num = 0, num_rects = 0;
-  gint                x, y, contig;
-  guint               w, h, d;
-  gint                baseh, basew;
-  XRectangle         *rects = NULL;
-  struct _gdk_span  **spans = NULL, *ptr1, *ptr2, *ptr3;
-  XWindowAttributes   xatt;
-  
-  XGetGeometry (disp, win, &rt, &x, &y, &w, &h, &d, &d);
-  if (h <= 0)
-    return;
-  basew = w;
-  baseh = h;
-  spans = g_malloc (sizeof (struct _gdk_span *) * h);
-  
-  for (i = 0; i < h; i++)
-    spans[i] = NULL;
-  XQueryTree (disp, win, &rt, &par, &list, (unsigned int *)&num);
-  if (list)
-    {
-      /* go through all child windows and create/insert spans */
-      for (i = 0; i < num; i++)
-       {
-         if (XGetWindowAttributes (disp, list[i], &xatt) && (xatt.map_state != IsUnmapped))
-           if (XGetGeometry (disp, list[i], &rt, &x, &y, &w, &h, &d, &d))
-             gdk_add_rectangles (disp, list[i], spans, basew, baseh, x, y);
-       }
-      if (merge)
-       gdk_add_rectangles (disp, win, spans, basew, baseh, x, y);
-      
-      /* go through the spans list and build a list of rects */
-      rects = g_malloc (sizeof (XRectangle) * 256);
-      num_rects = 0;
-      for (i = 0; i < baseh; i++)
-       {
-         ptr1 = spans[i];
-         /* go through the line for all spans */
-         while (ptr1)
-           {
-             rects[num_rects].x = ptr1->start;
-             rects[num_rects].y = i;
-             rects[num_rects].width = ptr1->end - ptr1->start + 1;
-             rects[num_rects].height = 1;
-             j = i + 1;
-             /* if there are more lines */
-             contig = 1;
-             /* while contigous rects (same start/end coords) exist */
-             while ((contig) && (j < baseh))
-               {
-                 /* search next line for spans matching this one */
-                 contig = 0;
-                 ptr2 = spans[j];
-                 ptr3 = NULL;
-                 while (ptr2)
-                   {
-                     /* if we have an exact span match set contig */
-                     if ((ptr2->start == ptr1->start) &&
-                         (ptr2->end == ptr1->end))
-                       {
-                         contig = 1;
-                         /* remove the span - not needed */
-                         if (ptr3)
-                           {
-                             ptr3->next = ptr2->next;
-                             g_free (ptr2);
-                             ptr2 = NULL;
-                           }
-                         else
-                           {
-                             spans[j] = ptr2->next;
-                             g_free (ptr2);
-                             ptr2 = NULL;
-                           }
-                         break;
-                       }
-                     /* gone past the span point no point looking */
-                     else if (ptr2->start < ptr1->start)
-                       break;
-                     if (ptr2)
-                       {
-                         ptr3 = ptr2;
-                         ptr2 = ptr2->next;
-                       }
-                   }
-                 /* if a contiguous span was found increase the rect h */
-                 if (contig)
-                   {
-                     rects[num_rects].height++;
-                     j++;
-                   }
-               }
-             /* up the rect count */
-             num_rects++;
-             /* every 256 new rects increase the rect array */
-             if ((num_rects % 256) == 0)
-               rects = g_realloc (rects, sizeof (XRectangle) * (num_rects + 256));
-             ptr1 = ptr1->next;
-           }
-       }
-      /* set the rects as the shape mask */
-      if (rects)
-       {
-         XShapeCombineRectangles (disp, win, ShapeBounding, 0, 0, rects, num_rects,
-                                  ShapeSet, YXSorted);
-         g_free (rects);
-       }
-      XFree (list);
-    }
-  /* free up all the spans we made */
-  for (i = 0; i < baseh; i++)
-    {
-      ptr1 = spans[i];
-      while (ptr1)
-       {
-         ptr2 = ptr1;
-         ptr1 = ptr1->next;
-         g_free (ptr2);
-       }
-    }
-  g_free (spans);
-}
-
-void
-gdk_window_set_child_shapes (GdkWindow *window)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-#ifdef HAVE_SHAPE_EXT
-  if (!GDK_DRAWABLE_DESTROYED (window) &&
-      gdk_window_have_shape_ext ())
-    gdk_propagate_shapes (GDK_DRAWABLE_XDISPLAY (window),
-                         GDK_DRAWABLE_XID (window), FALSE);
-#endif   
-}
-
-void
-gdk_window_merge_child_shapes (GdkWindow *window)
-{
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-#ifdef HAVE_SHAPE_EXT
-  if (!GDK_DRAWABLE_DESTROYED (window) &&
-      gdk_window_have_shape_ext ())
-    gdk_propagate_shapes (GDK_DRAWABLE_XDISPLAY (window),
-                         GDK_DRAWABLE_XID (window), TRUE);
-#endif   
-}
-
 /*************************************************************
  * gdk_window_is_visible:
  *     Check if the given window is mapped.
@@ -2436,7 +256,7 @@ gdk_window_is_viewable (GdkWindow *window)
   g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
   
   while (private && 
-        (private != &gdk_root_parent) &&
+        (private != (GdkWindowPrivate *)gdk_parent_root) &&
         (private->drawable.window_type != GDK_WINDOW_FOREIGN))
     {
       if (!private->mapped)
@@ -2448,136 +268,3 @@ gdk_window_is_viewable (GdkWindow *window)
   return TRUE;
 }
 
-/* Support for windows that can be guffaw-scrolled
- * (See http://www.gtk.org/~otaylor/whitepapers/guffaw-scrolling.txt)
- */
-
-static gboolean
-gdk_window_gravity_works (void)
-{
-  enum { UNKNOWN, NO, YES };
-  static gint gravity_works = UNKNOWN;
-  
-  if (gravity_works == UNKNOWN)
-    {
-      GdkWindowAttr attr;
-      GdkWindow *parent;
-      GdkWindow *child;
-      gint y;
-      
-      /* This particular server apparently has a bug so that the test
-       * works but the actual code crashes it
-       */
-      if ((!strcmp (XServerVendor (gdk_display), "Sun Microsystems, Inc.")) &&
-         (VendorRelease (gdk_display) == 3400))
-       {
-         gravity_works = NO;
-         return FALSE;
-       }
-      
-      attr.window_type = GDK_WINDOW_TEMP;
-      attr.wclass = GDK_INPUT_OUTPUT;
-      attr.x = 0;
-      attr.y = 0;
-      attr.width = 100;
-      attr.height = 100;
-      attr.event_mask = 0;
-      
-      parent = gdk_window_new (NULL, &attr, GDK_WA_X | GDK_WA_Y);
-      
-      attr.window_type = GDK_WINDOW_CHILD;
-      child = gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
-      
-      gdk_window_set_static_win_gravity (child, TRUE);
-      
-      gdk_window_resize (parent, 100, 110);
-      gdk_window_move (parent, 0, -10);
-      gdk_window_move_resize (parent, 0, 0, 100, 100);
-      
-      gdk_window_resize (parent, 100, 110);
-      gdk_window_move (parent, 0, -10);
-      gdk_window_move_resize (parent, 0, 0, 100, 100);
-      
-      gdk_window_get_geometry (child, NULL, &y, NULL, NULL, NULL);
-      
-      gdk_window_destroy (parent);
-      gdk_window_destroy (child);
-      
-      gravity_works = ((y == -20) ? YES : NO);
-    }
-  
-  return (gravity_works == YES);
-}
-
-static void
-gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on)
-{
-  XSetWindowAttributes xattributes;
-  
-  g_return_if_fail (window != NULL);
-  
-  xattributes.bit_gravity = on ? StaticGravity : ForgetGravity;
-  XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window),
-                          GDK_DRAWABLE_XID (window),
-                          CWBitGravity,  &xattributes);
-}
-
-static void
-gdk_window_set_static_win_gravity (GdkWindow *window, gboolean on)
-{
-  XSetWindowAttributes xattributes;
-  
-  g_return_if_fail (window != NULL);
-  
-  xattributes.win_gravity = on ? StaticGravity : NorthWestGravity;
-  
-  XChangeWindowAttributes (GDK_DRAWABLE_XDISPLAY (window),
-                          GDK_DRAWABLE_XID (window),
-                          CWWinGravity,  &xattributes);
-}
-
-/*************************************************************
- * gdk_window_set_static_gravities:
- *     Set the bit gravity of the given window to static,
- *     and flag it so all children get static subwindow
- *     gravity.
- *   arguments:
- *     window: window for which to set static gravity
- *     use_static: Whether to turn static gravity on or off.
- *   results:
- *     Does the XServer support static gravity?
- *************************************************************/
-
-gboolean 
-gdk_window_set_static_gravities (GdkWindow *window,
-                                gboolean   use_static)
-{
-  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
-  GList *tmp_list;
-  
-  g_return_val_if_fail (window != NULL, FALSE);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
-
-  if (!use_static == !private->guffaw_gravity)
-    return TRUE;
-  
-  if (use_static && !gdk_window_gravity_works ())
-    return FALSE;
-  
-  private->guffaw_gravity = use_static;
-  
-  if (!GDK_DRAWABLE_DESTROYED (window))
-    {
-      gdk_window_set_static_bit_gravity (window, use_static);
-      
-      tmp_list = private->children;
-      while (tmp_list)
-       {
-         gdk_window_set_static_win_gravity (window, use_static);
-         
-         tmp_list = tmp_list->next;
-       }
-    }
-  
-  return TRUE;
-}
index 263ad2bb0678355d0e8dfb1e7c456b2ecd707c74..7baf2c65703cf0264bef4cce9a5c829650cda4d8 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <gdk/gdkdrawable.h>
 #include <gdk/gdktypes.h>
+#include <gdk/gdkwindow.h>
+#include <gdk/gdkevents.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/gdk/gdkx.h b/gdk/gdkx.h
deleted file mode 100644 (file)
index 4f142bd..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#ifndef __GDK_X_H__
-#define __GDK_X_H__
-
-#include <gdk/gdkprivate.h>
-
-
-#define GDK_ROOT_WINDOW()             gdk_root_window
-#define GDK_ROOT_PARENT()             ((GdkWindow *)&gdk_root_parent)
-#define GDK_DISPLAY()                 gdk_display
-#define GDK_DRAWABLE_XDISPLAY(win)    (((GdkDrawablePrivate*) win)->xdisplay)
-#define GDK_DRAWABLE_XID(win)         (((GdkDrawablePrivate*) win)->xwindow)
-#define GDK_WINDOW_XDISPLAY           GDK_DRAWABLE_XDISPLAY
-#define GDK_WINDOW_XWINDOW            GDK_DRAWABLE_XID
-#define GDK_IMAGE_XDISPLAY(image)     (((GdkImagePrivate*) image)->xdisplay)
-#define GDK_IMAGE_XIMAGE(image)       (((GdkImagePrivate*) image)->ximage)
-#define GDK_GC_XDISPLAY(gc)           (((GdkGCPrivate*) gc)->xdisplay)
-#define GDK_GC_XGC(gc)                (((GdkGCPrivate*) gc)->xgc)
-#define GDK_COLORMAP_XDISPLAY(cmap)   (((GdkColormapPrivate*) cmap)->xdisplay)
-#define GDK_COLORMAP_XCOLORMAP(cmap)  (((GdkColormapPrivate*) cmap)->xcolormap)
-#define GDK_VISUAL_XVISUAL(vis)       (((GdkVisualPrivate*) vis)->xvisual)
-#define GDK_FONT_XDISPLAY(font)       (((GdkFontPrivate*) font)->xdisplay)
-#define GDK_FONT_XFONT(font)          (((GdkFontPrivate*) font)->xfont)
-
-
-GdkVisual*   gdkx_visual_get   (VisualID xvisualid);
-/* XXX: Do not use this function until it is fixed. An X Colormap
- *      is useless unless we also have the visual. */
-GdkColormap* gdkx_colormap_get (Colormap xcolormap);
-/* Utility function in gdk.c - not sure where it belongs, but it's
-   needed in more than one place, so make it public */
-Window        gdk_get_client_window      (Display  *dpy,
-                                          Window    win);
-
-/* Functions to create pixmaps and windows from their X equivalents */
-GdkPixmap    *gdk_pixmap_foreign_new (guint32     anid);
-GdkWindow    *gdk_window_foreign_new (guint32       anid);
-
-#endif /* __GDK_X_H__ */
diff --git a/gdk/gdkxid.c b/gdk/gdkxid.c
deleted file mode 100644 (file)
index 7067386..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include "gdkprivate.h"
-#include <stdio.h>
-
-static guint gdk_xid_hash    (XID *xid);
-static gint  gdk_xid_compare (XID *a,
-                             XID *b);
-
-
-static GHashTable *xid_ht = NULL;
-
-
-void
-gdk_xid_table_insert (XID      *xid,
-                     gpointer  data)
-{
-  g_return_if_fail (xid != NULL);
-
-  if (!xid_ht)
-    xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
-                              (GCompareFunc) gdk_xid_compare);
-
-  g_hash_table_insert (xid_ht, xid, data);
-}
-
-void
-gdk_xid_table_remove (XID xid)
-{
-  if (!xid_ht)
-    xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
-                              (GCompareFunc) gdk_xid_compare);
-
-  g_hash_table_remove (xid_ht, &xid);
-}
-
-gpointer
-gdk_xid_table_lookup (XID xid)
-{
-  gpointer data = NULL;
-
-  if (xid_ht)
-    data = g_hash_table_lookup (xid_ht, &xid);
-  
-  return data;
-}
-
-
-static guint
-gdk_xid_hash (XID *xid)
-{
-  return *xid;
-}
-
-static gint
-gdk_xid_compare (XID *a,
-                XID *b)
-{
-  return (*a == *b);
-}
index dbdfbbf6f0f125d3189d3b54e94674c6be3648cb..9ef45fe8d82608a16e2a90e45eadab0f07cdf413 100644 (file)
@@ -5137,6 +5137,46 @@ gdk_synthesize_click (GdkEvent *event,
   gdk_event_put (&temp_event);
 }
 
+void
+gdk_event_button_generate (GdkEvent *event)
+{
+  if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
+      (event->button.window == button_window[1]) &&
+      (event->button.button == button_number[1]))
+    {
+      gdk_synthesize_click (event, 3);
+      
+      button_click_time[1] = 0;
+      button_click_time[0] = 0;
+      button_window[1] = NULL;
+      button_window[0] = 0;
+      button_number[1] = -1;
+      button_number[0] = -1;
+    }
+  else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
+          (event->button.window == button_window[0]) &&
+          (event->button.button == button_number[0]))
+    {
+      gdk_synthesize_click (event, 2);
+      
+      button_click_time[1] = button_click_time[0];
+      button_click_time[0] = event->button.time;
+      button_window[1] = button_window[0];
+      button_window[0] = event->button.window;
+      button_number[1] = button_number[0];
+      button_number[0] = event->button.button;
+    }
+  else
+    {
+      button_click_time[1] = 0;
+      button_click_time[0] = event->button.time;
+      button_window[1] = NULL;
+      button_window[0] = event->button.window;
+      button_number[1] = -1;
+      button_number[0] = event->button.button;
+    }
+}
+
 /* Sends a ClientMessage to all toplevel client windows */
 gboolean
 gdk_event_send_client_message (GdkEvent *event, guint32 xid)
index dbdfbbf6f0f125d3189d3b54e94674c6be3648cb..9ef45fe8d82608a16e2a90e45eadab0f07cdf413 100644 (file)
@@ -5137,6 +5137,46 @@ gdk_synthesize_click (GdkEvent *event,
   gdk_event_put (&temp_event);
 }
 
+void
+gdk_event_button_generate (GdkEvent *event)
+{
+  if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
+      (event->button.window == button_window[1]) &&
+      (event->button.button == button_number[1]))
+    {
+      gdk_synthesize_click (event, 3);
+      
+      button_click_time[1] = 0;
+      button_click_time[0] = 0;
+      button_window[1] = NULL;
+      button_window[0] = 0;
+      button_number[1] = -1;
+      button_number[0] = -1;
+    }
+  else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
+          (event->button.window == button_window[0]) &&
+          (event->button.button == button_number[0]))
+    {
+      gdk_synthesize_click (event, 2);
+      
+      button_click_time[1] = button_click_time[0];
+      button_click_time[0] = event->button.time;
+      button_window[1] = button_window[0];
+      button_window[0] = event->button.window;
+      button_number[1] = button_number[0];
+      button_number[0] = event->button.button;
+    }
+  else
+    {
+      button_click_time[1] = 0;
+      button_click_time[0] = event->button.time;
+      button_window[1] = NULL;
+      button_window[0] = event->button.window;
+      button_number[1] = -1;
+      button_number[0] = event->button.button;
+    }
+}
+
 /* Sends a ClientMessage to all toplevel client windows */
 gboolean
 gdk_event_send_client_message (GdkEvent *event, guint32 xid)
index 1da1965a5514f8ef51a126344357da3b1e937dfd..6f9c12e429df5828da5d306b8e7bcad48b251a34 100644 (file)
@@ -3,6 +3,7 @@
 INCLUDES = @STRIP_BEGIN@       \
        -DG_LOG_DOMAIN=\"Gdk\"  \
        -I$(top_srcdir)         \
+       -I$(top_srcdir)/gdk     \
        @GTK_DEBUG_FLAGS@       \
        @GTK_XIM_FLAGS@         \
        @GTK_LOCALE_FLAGS@      \
@@ -19,10 +20,47 @@ LDADDS = @STRIP_BEGIN@      \
 
 noinst_LTLIBRARIES = libgdk-x11.la
 
-libgdk_x11_la_SOURCES =  \
-       gxid_lib.c       \
-       gxid_lib.h       \
-       gxid_proto.h
+if XINPUT_GXI
+xinput_sources =          \
+       gdkinput-x11.c     \
+       gdkinput-gxi.c
+else
+if XINPUT_XFREE
+xinput_sources =          \
+       gdkinput-x11.c     \
+       gdkinput-xfree.c
+else
+xinput_sources =
+       gdkinput-none.c
+endif
+endif
+
+libgdk_x11_la_SOURCES =    \
+       MwmUtil.h          \
+       gdkcc-x11.c        \
+       gdkcolor-x11.c     \
+       gdkcursor-x11.c    \
+       gdkdnd-x11.c       \
+       gdkdrawable-x11.c  \
+       gdkevents-x11.c    \
+       gdkfont-x11.c      \
+       gdkgc-x11.c        \
+       gdkglobals-x11.c   \
+       gdkim-x11.c        \
+       gdkimage-x11.c     \
+       gdkinput.c         \
+       gdkmain-x11.c      \
+       gdkpixmap-x11.c    \
+       gdkproperty-x11.c  \
+       gdkregion-x11.c    \
+       gdkselection-x11.c \
+       gdkvisual-x11.c    \
+       gdkwindow-x11.c    \
+       gdkxid.c           \
+       gxid_lib.c         \
+       gxid_lib.h         \
+       gxid_proto.h       \
+       $(xinput_sources)
 
 EXTRA_PROGRAMS = gxid
 bin_PROGRAMS = @xinput_progs@
@@ -30,7 +68,4 @@ bin_PROGRAMS = @xinput_progs@
 gxid_SOURCES = gxid.c
 gxid_LDADD = $(LDADDS)
 
-#EXTRA_DIST = \
-#      MwmUtil.h         \
-
 
index f592fa8e5446ec8a32ac0f1954f67c03939f3d89..91e873453b7f37d77025425ecc823e05effbab86 100644 (file)
@@ -61,6 +61,7 @@
  */
 
 #include <X11/Xlib.h>
+#include <X11/Xutil.h>
 #include <stdlib.h>
 #include <string.h>
 
index 03222cc3d6199d8520cbf57ff5a82b1421a9e555..26994cbe8b2ac26e31328d0bf095ba98d584c803 100644 (file)
  */
 
 #include <time.h>
-#include <X11/Xlib.h>
 
 #include "gdkcolor.h"
-#include "gdkprivate.h"
-
+#include "gdkx.h"
 
 static gint  gdk_colormap_match_color (GdkColormap *cmap,
                                       GdkColor    *color,
@@ -39,7 +37,6 @@ static void  gdk_colormap_remove      (GdkColormap *cmap);
 static guint gdk_colormap_hash        (Colormap    *cmap);
 static gint  gdk_colormap_cmp         (Colormap    *a,
                                       Colormap    *b);
-static void gdk_colormap_real_destroy (GdkColormap *colormap);
 
 static GHashTable *colormap_hash = NULL;
 
@@ -49,19 +46,19 @@ gdk_colormap_new (GdkVisual *visual,
                  gint       private_cmap)
 {
   GdkColormap *colormap;
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   Visual *xvisual;
   int size;
   int i;
 
   g_return_val_if_fail (visual != NULL, NULL);
 
-  private = g_new (GdkColormapPrivate, 1);
+  private = g_new (GdkColormapPrivateX, 1);
   colormap = (GdkColormap*) private;
 
   private->xdisplay = gdk_display;
-  private->visual = visual;
-  private->ref_count = 1;
+  private->base.visual = visual;
+  private->base.ref_count = 1;
 
   private->hash = NULL;
   private->last_sync_time = 0;
@@ -148,13 +145,10 @@ gdk_colormap_new (GdkVisual *visual,
   return colormap;
 }
 
-static void
-gdk_colormap_real_destroy (GdkColormap *colormap)
+void
+_gdk_colormap_real_destroy (GdkColormap *colormap)
 {
-  GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
-
-  g_return_if_fail (colormap != NULL);
-  g_return_if_fail (private->ref_count == 0);
+  GdkColormapPrivateX *private = (GdkColormapPrivateX*) colormap;
 
   gdk_colormap_remove (colormap);
   XFreeColormap (private->xdisplay, private->xcolormap);
@@ -167,42 +161,6 @@ gdk_colormap_real_destroy (GdkColormap *colormap)
   g_free (colormap);
 }
 
-GdkColormap*
-gdk_colormap_ref (GdkColormap *cmap)
-{
-  GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
-
-  g_return_val_if_fail (cmap != NULL, NULL);
-
-  private->ref_count += 1;
-  return cmap;
-}
-
-void
-gdk_colormap_unref (GdkColormap *cmap)
-{
-  GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
-
-  g_return_if_fail (cmap != NULL);
-  g_return_if_fail (private->ref_count > 0);
-
-  private->ref_count -= 1;
-  if (private->ref_count == 0)
-    gdk_colormap_real_destroy (cmap);
-}
-
-GdkVisual *
-gdk_colormap_get_visual (GdkColormap *colormap)
-{
-  GdkColormapPrivate *private;
-
-  g_return_val_if_fail (colormap != NULL, NULL);
-  
-  private = (GdkColormapPrivate *)colormap;
-
-  return private->visual;
-}
-     
 #define MIN_SYNC_TIME 2
 
 void
@@ -210,7 +168,7 @@ gdk_colormap_sync (GdkColormap *colormap,
                   gboolean     force)
 {
   time_t current_time;
-  GdkColormapPrivate *private = (GdkColormapPrivate *)colormap;
+  GdkColormapPrivateX *private = (GdkColormapPrivateX *)colormap;
   XColor *xpalette;
   gint nlookup;
   gint i;
@@ -257,28 +215,28 @@ GdkColormap*
 gdk_colormap_get_system (void)
 {
   static GdkColormap *colormap = NULL;
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
 
   if (!colormap)
     {
-      private = g_new (GdkColormapPrivate, 1);
+      private = g_new (GdkColormapPrivateX, 1);
       colormap = (GdkColormap*) private;
 
       private->xdisplay = gdk_display;
       private->xcolormap = DefaultColormap (gdk_display, gdk_screen);
-      private->visual = gdk_visual_get_system ();
+      private->base.visual = gdk_visual_get_system ();
       private->private_val = FALSE;
-      private->ref_count = 1;
+      private->base.ref_count = 1;
 
       private->hash = NULL;
       private->last_sync_time = 0;
       private->info = NULL;
 
       colormap->colors = NULL;
-      colormap->size = private->visual->colormap_size;
+      colormap->size = private->base.visual->colormap_size;
 
-      if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
-         (private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
+      if ((private->base.visual->type == GDK_VISUAL_GRAYSCALE) ||
+         (private->base.visual->type == GDK_VISUAL_PSEUDO_COLOR))
        {
          private->info = g_new0 (GdkColorInfo, colormap->size);
          colormap->colors = g_new (GdkColor, colormap->size);
@@ -305,7 +263,7 @@ void
 gdk_colormap_change (GdkColormap *colormap,
                     gint         ncolors)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   GdkVisual *visual;
   XColor *palette;
   gint shift;
@@ -317,8 +275,8 @@ gdk_colormap_change (GdkColormap *colormap,
 
   palette = g_new (XColor, ncolors);
 
-  private = (GdkColormapPrivate*) colormap;
-  switch (private->visual->type)
+  private = (GdkColormapPrivateX*) colormap;
+  switch (private->base.visual->type)
     {
     case GDK_VISUAL_GRAYSCALE:
     case GDK_VISUAL_PSEUDO_COLOR:
@@ -335,7 +293,7 @@ gdk_colormap_change (GdkColormap *colormap,
       break;
 
     case GDK_VISUAL_DIRECT_COLOR:
-      visual = private->visual;
+      visual = private->base.visual;
 
       shift = visual->red_shift;
       max_colors = 1 << visual->red_prec;
@@ -384,24 +342,6 @@ gdk_colormap_change (GdkColormap *colormap,
   g_free (palette);
 }
 
-void
-gdk_colors_store (GdkColormap   *colormap,
-                 GdkColor      *colors,
-                 gint           ncolors)
-{
-  gint i;
-
-  for (i = 0; i < ncolors; i++)
-    {
-      colormap->colors[i].pixel = colors[i].pixel;
-      colormap->colors[i].red = colors[i].red;
-      colormap->colors[i].green = colors[i].green;
-      colormap->colors[i].blue = colors[i].blue;
-    }
-
-  gdk_colormap_change (colormap, ncolors);
-}
-
 gboolean
 gdk_colors_alloc (GdkColormap   *colormap,
                  gint           contiguous,
@@ -410,13 +350,13 @@ gdk_colors_alloc (GdkColormap   *colormap,
                  gulong        *pixels,
                  gint           npixels)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   gint return_val;
   gint i;
 
   g_return_val_if_fail (colormap != NULL, 0);
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
 
   return_val = XAllocColorCells (private->xdisplay, private->xcolormap,
                                 contiguous, planes, nplanes, pixels, npixels);
@@ -433,108 +373,6 @@ gdk_colors_alloc (GdkColormap   *colormap,
   return return_val != 0;
 }
 
-/*
- *--------------------------------------------------------------
- * gdk_color_copy
- *
- *   Copy a color structure into new storage.
- *
- * Arguments:
- *   "color" is the color struct to copy.
- *
- * Results:
- *   A new color structure.  Free it with gdk_color_free.
- *
- *--------------------------------------------------------------
- */
-
-static GMemChunk *color_chunk;
-
-GdkColor*
-gdk_color_copy (GdkColor *color)
-{
-  GdkColor *new_color;
-  
-  g_return_val_if_fail (color != NULL, NULL);
-
-  if (color_chunk == NULL)
-    color_chunk = g_mem_chunk_new ("colors",
-                                  sizeof (GdkColor),
-                                  4096,
-                                  G_ALLOC_AND_FREE);
-
-  new_color = g_chunk_new (GdkColor, color_chunk);
-  *new_color = *color;
-  return new_color;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_color_free
- *
- *   Free a color structure obtained from gdk_color_copy.  Do not use
- *   with other color structures.
- *
- * Arguments:
- *   "color" is the color struct to free.
- *
- *-------------------------------------------------------------- */
-
-void
-gdk_color_free (GdkColor *color)
-{
-  g_assert (color_chunk != NULL);
-  g_return_if_fail (color != NULL);
-
-  g_mem_chunk_free (color_chunk, color);
-}
-
-gboolean
-gdk_color_white (GdkColormap *colormap,
-                GdkColor    *color)
-{
-  gint return_val;
-
-  g_return_val_if_fail (colormap != NULL, FALSE);
-
-  if (color)
-    {
-      color->pixel = WhitePixel (gdk_display, gdk_screen);
-      color->red = 65535;
-      color->green = 65535;
-      color->blue = 65535;
-
-      return_val = gdk_color_alloc (colormap, color);
-    }
-  else
-    return_val = FALSE;
-
-  return return_val;
-}
-
-gboolean
-gdk_color_black (GdkColormap *colormap,
-                GdkColor    *color)
-{
-  gint return_val;
-
-  g_return_val_if_fail (colormap != NULL, FALSE);
-
-  if (color)
-    {
-      color->pixel = BlackPixel (gdk_display, gdk_screen);
-      color->red = 0;
-      color->green = 0;
-      color->blue = 0;
-
-      return_val = gdk_color_alloc (colormap, color);
-    }
-  else
-    return_val = FALSE;
-
-  return return_val;
-}
-
 gboolean
 gdk_color_parse (const gchar *spec,
                 GdkColor *color)
@@ -570,7 +408,7 @@ gdk_colors_free (GdkColormap *colormap,
                 gint         in_npixels,
                 gulong       planes)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   gulong *pixels;
   gint npixels = 0;
   gint i;
@@ -578,10 +416,10 @@ gdk_colors_free (GdkColormap *colormap,
   g_return_if_fail (colormap != NULL);
   g_return_if_fail (in_pixels != NULL);
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
 
-  if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
-      (private->visual->type != GDK_VISUAL_GRAYSCALE))
+  if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
+      (private->base.visual->type != GDK_VISUAL_GRAYSCALE))
     return;
   
   pixels = g_new (gulong, in_npixels);
@@ -618,7 +456,7 @@ gdk_colormap_free_colors (GdkColormap *colormap,
                          GdkColor    *colors,
                          gint         ncolors)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   gulong *pixels;
   gint npixels = 0;
   gint i;
@@ -626,10 +464,10 @@ gdk_colormap_free_colors (GdkColormap *colormap,
   g_return_if_fail (colormap != NULL);
   g_return_if_fail (colors != NULL);
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
 
-  if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
-      (private->visual->type != GDK_VISUAL_GRAYSCALE))
+  if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
+      (private->base.visual->type != GDK_VISUAL_GRAYSCALE))
     return;
 
   pixels = g_new (gulong, ncolors);
@@ -671,10 +509,10 @@ gdk_colormap_alloc1 (GdkColormap *colormap,
                     GdkColor    *color,
                     GdkColor    *ret)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   XColor xcolor;
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
 
   xcolor.red = color->red;
   xcolor.green = color->green;
@@ -723,12 +561,12 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
                                     gboolean     best_match,
                                     gboolean    *success)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   gulong *pixels;
   Status status;
   gint i, index;
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
 
   if (private->private_val)
     {
@@ -781,13 +619,13 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap,
                                   gboolean     best_match,
                                   gboolean    *success)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   gint i, index;
   XColor *store = g_new (XColor, ncolors);
   gint nstore = 0;
   gint nremaining = 0;
   
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
   index = -1;
 
   /* First, store the colors we have room for */
@@ -860,12 +698,12 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
                                  gboolean     best_match,
                                  gboolean    *success)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   gint i, index;
   gint nremaining = 0;
   gint nfailed = 0;
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
   index = -1;
 
   for (i=0; i<ncolors; i++)
@@ -952,12 +790,12 @@ gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
                                       gboolean     best_match,
                                       gboolean    *success)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   GdkColor *lookup_color;
   gint i;
   gint nremaining = 0;
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
 
   /* Check for an exact match among previously allocated colors */
 
@@ -999,7 +837,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
                           gboolean     best_match,
                           gboolean    *success)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   GdkVisual *visual;
   gint i;
   gint nremaining = 0;
@@ -1008,14 +846,14 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
   g_return_val_if_fail (colormap != NULL, FALSE);
   g_return_val_if_fail (colors != NULL, FALSE);
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
 
   for (i=0; i<ncolors; i++)
     {
       success[i] = FALSE;
     }
 
-  switch (private->visual->type)
+  switch (private->base.visual->type)
     {
     case GDK_VISUAL_PSEUDO_COLOR:
     case GDK_VISUAL_GRAYSCALE:
@@ -1029,7 +867,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
 
     case GDK_VISUAL_DIRECT_COLOR:
     case GDK_VISUAL_TRUE_COLOR:
-      visual = private->visual;
+      visual = private->base.visual;
 
       for (i=0; i<ncolors; i++)
        {
@@ -1063,36 +901,11 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
   return nremaining;
 }
 
-gboolean
-gdk_colormap_alloc_color (GdkColormap *colormap,
-                         GdkColor    *color,
-                         gboolean     writeable,
-                         gboolean     best_match)
-{
-  gboolean success;
-
-  gdk_colormap_alloc_colors (colormap, color, 1, writeable, best_match,
-                            &success);
-
-  return success;
-}
-
-gboolean
-gdk_color_alloc (GdkColormap *colormap,
-                GdkColor    *color)
-{
-  gboolean success;
-
-  gdk_colormap_alloc_colors (colormap, color, 1, FALSE, TRUE, &success);
-
-  return success;
-}
-
 gboolean
 gdk_color_change (GdkColormap *colormap,
                  GdkColor    *color)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
   XColor xcolor;
 
   g_return_val_if_fail (colormap != NULL, FALSE);
@@ -1104,33 +917,12 @@ gdk_color_change (GdkColormap *colormap,
   xcolor.blue = color->blue;
   xcolor.flags = DoRed | DoGreen | DoBlue;
 
-  private = (GdkColormapPrivate*) colormap;
+  private = (GdkColormapPrivateX*) colormap;
   XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
 
   return TRUE;
 }
 
-guint
-gdk_color_hash (const GdkColor *colora)
-{
-  return ((colora->red) +
-         (colora->green << 11) +
-         (colora->blue << 22) +
-         (colora->blue >> 6));
-}
-
-gint
-gdk_color_equal (const GdkColor *colora,
-                const GdkColor *colorb)
-{
-  g_return_val_if_fail (colora != NULL, FALSE);
-  g_return_val_if_fail (colorb != NULL, FALSE);
-
-  return ((colora->red == colorb->red) &&
-         (colora->green == colorb->green) &&
-         (colora->blue == colorb->blue));
-}
-
 /* XXX: Do not use this function until it is fixed. An X Colormap
  *      is useless unless we also have the visual.
  */
@@ -1138,7 +930,7 @@ GdkColormap*
 gdkx_colormap_get (Colormap xcolormap)
 {
   GdkColormap *colormap;
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
 
   colormap = gdk_colormap_lookup (xcolormap);
   if (colormap)
@@ -1147,12 +939,12 @@ gdkx_colormap_get (Colormap xcolormap)
   if (xcolormap == DefaultColormap (gdk_display, gdk_screen))
     return gdk_colormap_get_system ();
 
-  private = g_new (GdkColormapPrivate, 1);
+  private = g_new (GdkColormapPrivateX, 1);
   colormap = (GdkColormap*) private;
 
   private->xdisplay = gdk_display;
   private->xcolormap = xcolormap;
-  private->visual = NULL;
+  private->base.visual = NULL;
   private->private_val = TRUE;
 
   /* To do the following safely, we would have to have some way of finding
@@ -1243,13 +1035,13 @@ gdk_colormap_lookup (Colormap xcolormap)
 static void
 gdk_colormap_add (GdkColormap *cmap)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
 
   if (!colormap_hash)
     colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
                                      (GCompareFunc) gdk_colormap_cmp);
 
-  private = (GdkColormapPrivate*) cmap;
+  private = (GdkColormapPrivateX*)cmap;
 
   g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
 }
@@ -1257,13 +1049,13 @@ gdk_colormap_add (GdkColormap *cmap)
 static void
 gdk_colormap_remove (GdkColormap *cmap)
 {
-  GdkColormapPrivate *private;
+  GdkColormapPrivateX *private;
 
   if (!colormap_hash)
     colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
                                      (GCompareFunc) gdk_colormap_cmp);
 
-  private = (GdkColormapPrivate*) cmap;
+  private = (GdkColormapPrivateX *)cmap;
 
   g_hash_table_remove (colormap_hash, &private->xcolormap);
 }
index 04260a2cde91fa0c40395b06d1dfd7eeb8dc0fdc..66d0f34ddc66cfa020554c5eb4966ae01c8fd896 100644 (file)
@@ -29,8 +29,6 @@
 
 #include "gdkx.h"
 #include "gdkcursor.h"
-#include "gdkprivate.h"
-
 
 GdkCursor*
 gdk_cursor_new (GdkCursorType cursor_type)
index a58da225b1938921b2c991820e22b69f01e559dd..653f2086d4bb8b83e63dba5c9dfcf95a67a84e51 100644 (file)
@@ -201,12 +201,12 @@ gdk_drag_context_find (gboolean is_source,
       context_dest_xid = context->dest_window ? 
                           (private->drop_xid ?
                              private->drop_xid :
-                             GDK_WINDOW_XWINDOW (context->dest_window)) :
+                             GDK_DRAWABLE_XID (context->dest_window)) :
                           None;
 
       if ((!context->is_source == !is_source) &&
          ((source_xid == None) || (context->source_window &&
-           (GDK_WINDOW_XWINDOW (context->source_window) == source_xid))) &&
+           (GDK_DRAWABLE_XID (context->source_window) == source_xid))) &&
          ((dest_xid == None) || (context_dest_xid == dest_xid)))
        return context;
       
@@ -372,7 +372,7 @@ gdk_window_cache_new (void)
   result->old_event_mask = xwa.your_event_mask;
   XSelectInput (gdk_display, gdk_root_window,
                result->old_event_mask | SubstructureNotifyMask);
-  gdk_window_add_filter ((GdkWindow *)&gdk_root_parent, 
+  gdk_window_add_filter (gdk_parent_root, 
                         gdk_window_cache_filter, result);
   
   gdk_error_code = 0;
@@ -411,7 +411,7 @@ static void
 gdk_window_cache_destroy (GdkWindowCache *cache)
 {
   XSelectInput (gdk_display, gdk_root_window, cache->old_event_mask);
-  gdk_window_remove_filter ((GdkWindow *)&gdk_root_parent, 
+  gdk_window_remove_filter (gdk_parent_root, 
                            gdk_window_cache_filter, cache);
 
   g_list_foreach (cache->children, (GFunc)g_free, NULL);
@@ -1273,8 +1273,8 @@ motif_set_targets (GdkDragContext *context)
 
   info.selection_atom = private->motif_selection;
 
-  XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
-                  GDK_WINDOW_XWINDOW (context->source_window),
+  XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
+                  GDK_DRAWABLE_XID (context->source_window),
                   private->motif_selection,
                   motif_drag_initiator_info, 8, PropModeReplace,
                   (guchar *)&info, sizeof (info));
@@ -1333,24 +1333,24 @@ motif_send_enter (GdkDragContext  *context,
   xev.xclient.type = ClientMessage;
   xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
   xev.xclient.format = 8;
-  xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
+  xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
 
   MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_ENTER;
   MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
   MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
   MOTIF_XCLIENT_LONG (&xev, 1) = time;
-  MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XWINDOW (context->source_window);
+  MOTIF_XCLIENT_LONG (&xev, 2) = GDK_DRAWABLE_XID (context->source_window);
 
   if (!private->motif_targets_set)
     motif_set_targets (context);
 
   MOTIF_XCLIENT_LONG (&xev, 3) = private->motif_selection;
 
-  if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
+  if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
                        FALSE, 0, &xev))
     GDK_NOTE (DND, 
              g_message ("Send event to %lx failed",
-                        GDK_WINDOW_XWINDOW (context->dest_window)));
+                        GDK_DRAWABLE_XID (context->dest_window)));
 }
 
 static void
@@ -1362,20 +1362,20 @@ motif_send_leave (GdkDragContext  *context,
   xev.xclient.type = ClientMessage;
   xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
   xev.xclient.format = 8;
-  xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
+  xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
 
   MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_LEAVE;
   MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
   MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
   MOTIF_XCLIENT_LONG (&xev, 1) = time;
-  MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XWINDOW (context->source_window);
+  MOTIF_XCLIENT_LONG (&xev, 2) = GDK_DRAWABLE_XID (context->source_window);
   MOTIF_XCLIENT_LONG (&xev, 3) = 0;
 
-  if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
+  if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
                        FALSE, 0, &xev))
     GDK_NOTE (DND, 
              g_message ("Send event to %lx failed",
-                        GDK_WINDOW_XWINDOW (context->dest_window)));
+                        GDK_DRAWABLE_XID (context->dest_window)));
 }
 
 static gboolean
@@ -1392,7 +1392,7 @@ motif_send_motion (GdkDragContext  *context,
   xev.xclient.type = ClientMessage;
   xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
   xev.xclient.format = 8;
-  xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
+  xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
 
   MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
   MOTIF_XCLIENT_SHORT (&xev, 1) = motif_dnd_get_flags (context);
@@ -1417,11 +1417,11 @@ motif_send_motion (GdkDragContext  *context,
       retval = FALSE;
     }
 
-  if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
+  if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
                        FALSE, 0, &xev))
     GDK_NOTE (DND, 
              g_message ("Send event to %lx failed",
-                        GDK_WINDOW_XWINDOW (context->dest_window)));
+                        GDK_DRAWABLE_XID (context->dest_window)));
 
   return retval;
 }
@@ -1435,7 +1435,7 @@ motif_send_drop (GdkDragContext *context, guint32 time)
   xev.xclient.type = ClientMessage;
   xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
   xev.xclient.format = 8;
-  xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
+  xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
 
   MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START;
   MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
@@ -1446,13 +1446,13 @@ motif_send_drop (GdkDragContext *context, guint32 time)
   MOTIF_XCLIENT_SHORT (&xev, 5) = private->last_y;
 
   MOTIF_XCLIENT_LONG (&xev, 3)  = private->motif_selection;
-  MOTIF_XCLIENT_LONG (&xev, 4)  = GDK_WINDOW_XWINDOW (context->source_window);
+  MOTIF_XCLIENT_LONG (&xev, 4)  = GDK_DRAWABLE_XID (context->source_window);
 
-  if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
+  if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
                        FALSE, 0, &xev))
     GDK_NOTE (DND, 
              g_message ("Send event to %lx failed",
-                        GDK_WINDOW_XWINDOW (context->dest_window)));
+                        GDK_DRAWABLE_XID (context->dest_window)));
 }
 
 /* Target Side */
@@ -1756,7 +1756,7 @@ motif_drag_status (GdkEvent *event,
            g_message ("Motif status message: flags %x", flags));
 
   context = gdk_drag_context_find (TRUE, 
-                                  GDK_WINDOW_XWINDOW (event->any.window), 
+                                  GDK_DRAWABLE_XID (event->any.window), 
                                   None);
 
   if (context)
@@ -2028,8 +2028,8 @@ xdnd_set_targets (GdkDragContext *context)
       i++;
     }
 
-  XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
-                  GDK_WINDOW_XWINDOW (context->source_window),
+  XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
+                  GDK_DRAWABLE_XID (context->source_window),
                   gdk_atom_intern ("XdndTypeList", FALSE),
                   XA_ATOM, 32, PropModeReplace,
                   (guchar *)atomlist, n_atoms);
@@ -2076,8 +2076,8 @@ xdnd_set_actions (GdkDragContext *context)
        }
     }
 
-  XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
-                  GDK_WINDOW_XWINDOW (context->source_window),
+  XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
+                  GDK_DRAWABLE_XID (context->source_window),
                   gdk_atom_intern ("XdndActionList", FALSE),
                   XA_ATOM, 32, PropModeReplace,
                   (guchar *)atomlist, n_atoms);
@@ -2119,8 +2119,8 @@ xdnd_send_enter (GdkDragContext *context)
   xev.xclient.format = 32;
   xev.xclient.window = private->drop_xid ? 
                            private->drop_xid : 
-                           GDK_WINDOW_XWINDOW (context->dest_window);
-  xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
+                           GDK_DRAWABLE_XID (context->dest_window);
+  xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
   xev.xclient.data.l[1] = (3 << 24); /* version */
   xev.xclient.data.l[2] = 0;
   xev.xclient.data.l[3] = 0;
@@ -2148,12 +2148,12 @@ xdnd_send_enter (GdkDragContext *context)
        }
     }
 
-  if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
+  if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
                         FALSE, &xev))
     {
       GDK_NOTE (DND, 
                g_message ("Send event to %lx failed",
-                          GDK_WINDOW_XWINDOW (context->dest_window)));
+                          GDK_DRAWABLE_XID (context->dest_window)));
       gdk_window_unref (context->dest_window);
       context->dest_window = NULL;
     }
@@ -2171,19 +2171,19 @@ xdnd_send_leave (GdkDragContext *context)
   xev.xclient.format = 32;
   xev.xclient.window = private->drop_xid ? 
                            private->drop_xid : 
-                           GDK_WINDOW_XWINDOW (context->dest_window);
-  xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
+                           GDK_DRAWABLE_XID (context->dest_window);
+  xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
   xev.xclient.data.l[1] = 0;
   xev.xclient.data.l[2] = 0;
   xev.xclient.data.l[3] = 0;
   xev.xclient.data.l[4] = 0;
 
-  if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
+  if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
                         FALSE, &xev))
     {
       GDK_NOTE (DND, 
                g_message ("Send event to %lx failed",
-                          GDK_WINDOW_XWINDOW (context->dest_window)));
+                          GDK_DRAWABLE_XID (context->dest_window)));
       gdk_window_unref (context->dest_window);
       context->dest_window = NULL;
     }
@@ -2200,19 +2200,19 @@ xdnd_send_drop (GdkDragContext *context, guint32 time)
   xev.xclient.format = 32;
   xev.xclient.window = private->drop_xid ? 
                            private->drop_xid : 
-                           GDK_WINDOW_XWINDOW (context->dest_window);
-  xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
+                           GDK_DRAWABLE_XID (context->dest_window);
+  xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
   xev.xclient.data.l[1] = 0;
   xev.xclient.data.l[2] = time;
   xev.xclient.data.l[3] = 0;
   xev.xclient.data.l[4] = 0;
 
-  if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
+  if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
                         FALSE, &xev))
     {
       GDK_NOTE (DND, 
                g_message ("Send event to %lx failed",
-                          GDK_WINDOW_XWINDOW (context->dest_window)));
+                          GDK_DRAWABLE_XID (context->dest_window)));
       gdk_window_unref (context->dest_window);
       context->dest_window = NULL;
     }
@@ -2233,19 +2233,19 @@ xdnd_send_motion (GdkDragContext *context,
   xev.xclient.format = 32;
   xev.xclient.window = private->drop_xid ? 
                            private->drop_xid : 
-                           GDK_WINDOW_XWINDOW (context->dest_window);
-  xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
+                           GDK_DRAWABLE_XID (context->dest_window);
+  xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
   xev.xclient.data.l[1] = 0;
   xev.xclient.data.l[2] = (x_root << 16) | y_root;
   xev.xclient.data.l[3] = time;
   xev.xclient.data.l[4] = xdnd_action_to_atom (action);
 
-  if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->dest_window),
+  if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->dest_window),
                         FALSE, &xev))
     {
       GDK_NOTE (DND, 
                g_message ("Send event to %lx failed",
-                          GDK_WINDOW_XWINDOW (context->dest_window)));
+                          GDK_DRAWABLE_XID (context->dest_window)));
       gdk_window_unref (context->dest_window);
       context->dest_window = NULL;
     }
@@ -2345,8 +2345,8 @@ xdnd_read_actions (GdkDragContext *context)
 
   /* Get the XdndActionList, if set */
 
-  XGetWindowProperty (GDK_WINDOW_XDISPLAY (context->source_window),
-                     GDK_WINDOW_XWINDOW (context->source_window),
+  XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
+                     GDK_DRAWABLE_XID (context->source_window),
                      gdk_atom_intern ("XdndActionList", FALSE), 0, 65536,
                      False, XA_ATOM, &type, &format, &nitems,
                      &after, (guchar **)&data);
@@ -2511,7 +2511,7 @@ xdnd_enter_filter (GdkXEvent *xev,
   new_context->targets = NULL;
   if (get_types)
     {
-      XGetWindowProperty (GDK_WINDOW_XDISPLAY (event->any.window), 
+      XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (event->any.window), 
                          source_window, 
                          gdk_atom_intern ("XdndTypeList", FALSE), 0, 65536,
                          False, XA_ATOM, &type, &format, &nitems,
@@ -2570,7 +2570,7 @@ xdnd_leave_filter (GdkXEvent *xev,
 
   if ((current_dest_drag != NULL) &&
       (current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
-      (GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
+      (GDK_DRAWABLE_XID (current_dest_drag->source_window) == source_window))
     {
       event->dnd.type = GDK_DRAG_LEAVE;
       /* Pass ownership of context to the event */
@@ -2603,7 +2603,7 @@ xdnd_position_filter (GdkXEvent *xev,
   
   if ((current_dest_drag != NULL) &&
       (current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
-      (GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
+      (GDK_DRAWABLE_XID (current_dest_drag->source_window) == source_window))
     {
       event->dnd.type = GDK_DRAG_MOTION;
       event->dnd.context = current_dest_drag;
@@ -2642,7 +2642,7 @@ xdnd_drop_filter (GdkXEvent *xev,
 
   if ((current_dest_drag != NULL) &&
       (current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
-      (GDK_WINDOW_XWINDOW (current_dest_drag->source_window) == source_window))
+      (GDK_DRAWABLE_XID (current_dest_drag->source_window) == source_window))
     {
       GdkDragContextPrivate *private;
       private = (GdkDragContextPrivate *)current_dest_drag;
@@ -2843,7 +2843,7 @@ gdk_drag_find_window (GdkDragContext  *context,
 
   dest = get_client_window_at_coords (private->window_cache,
                                      drag_window ? 
-                                     GDK_WINDOW_XWINDOW (drag_window) : GDK_NONE,
+                                     GDK_DRAWABLE_XID (drag_window) : GDK_NONE,
                                      x_root, y_root);
 
   if (private->dest_xid != dest)
@@ -3077,7 +3077,7 @@ gdk_drag_status (GdkDragContext   *context,
       xev.xclient.type = ClientMessage;
       xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE);
       xev.xclient.format = 8;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
+      xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
 
       if (private->drag_status == GDK_DRAG_STATUS_ACTION_WAIT)
        {
@@ -3123,30 +3123,30 @@ gdk_drag_status (GdkDragContext   *context,
       MOTIF_XCLIENT_SHORT (&xev, 4) = private->last_x;
       MOTIF_XCLIENT_SHORT (&xev, 5) = private->last_y;
 
-      if (!gdk_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
+      if (!gdk_send_xevent (GDK_DRAWABLE_XID (context->source_window),
                       FALSE, 0, &xev))
        GDK_NOTE (DND, 
                  g_message ("Send event to %lx failed",
-                            GDK_WINDOW_XWINDOW (context->source_window)));
+                            GDK_DRAWABLE_XID (context->source_window)));
     }
   else if (context->protocol == GDK_DRAG_PROTO_XDND)
     {
       xev.xclient.type = ClientMessage;
       xev.xclient.message_type = gdk_atom_intern ("XdndStatus", FALSE);
       xev.xclient.format = 32;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
+      xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
 
-      xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->dest_window);
+      xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->dest_window);
       xev.xclient.data.l[1] = (action != 0) ? (2 | 1) : 0;
       xev.xclient.data.l[2] = 0;
       xev.xclient.data.l[3] = 0;
       xev.xclient.data.l[4] = xdnd_action_to_atom (action);
 
-      if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
+      if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->source_window),
                             FALSE, &xev))
        GDK_NOTE (DND, 
                  g_message ("Send event to %lx failed",
-                            GDK_WINDOW_XWINDOW (context->source_window)));
+                            GDK_DRAWABLE_XID (context->source_window)));
     }
 
   private->old_action = action;
@@ -3186,7 +3186,7 @@ gdk_drop_reply (GdkDragContext   *context,
       MOTIF_XCLIENT_SHORT (&xev, 2) = private->last_x;
       MOTIF_XCLIENT_SHORT (&xev, 3) = private->last_y;
       
-      gdk_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
+      gdk_send_xevent (GDK_DRAWABLE_XID (context->source_window),
                       FALSE, 0, &xev);
     }
 }
@@ -3205,19 +3205,19 @@ gdk_drop_finish (GdkDragContext   *context,
       xev.xclient.type = ClientMessage;
       xev.xclient.message_type = gdk_atom_intern ("XdndFinished", FALSE);
       xev.xclient.format = 32;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (context->source_window);
+      xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
 
-      xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->dest_window);
+      xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->dest_window);
       xev.xclient.data.l[1] = 0;
       xev.xclient.data.l[2] = 0;
       xev.xclient.data.l[3] = 0;
       xev.xclient.data.l[4] = 0;
 
-      if (!xdnd_send_xevent (GDK_WINDOW_XWINDOW (context->source_window),
+      if (!xdnd_send_xevent (GDK_DRAWABLE_XID (context->source_window),
                             FALSE, &xev))
        GDK_NOTE (DND, 
                  g_message ("Send event to %lx failed",
-                            GDK_WINDOW_XWINDOW (context->source_window)));
+                            GDK_DRAWABLE_XID (context->source_window)));
     }
 }
 
@@ -3242,7 +3242,7 @@ gdk_window_register_dnd (GdkWindow      *window)
   info.num_drop_sites = 0;
   info.total_size = sizeof(info);
 
-  XChangeProperty (gdk_display, GDK_WINDOW_XWINDOW (window),
+  XChangeProperty (gdk_display, GDK_DRAWABLE_XID (window),
                   motif_drag_receiver_info_atom,
                   motif_drag_receiver_info_atom,
                   8, PropModeReplace,
@@ -3255,8 +3255,8 @@ gdk_window_register_dnd (GdkWindow      *window)
     xdnd_aware_atom = gdk_atom_intern ("XdndAware", FALSE);
 
   /* The property needs to be of type XA_ATOM, not XA_INTEGER. Blech */
-  XChangeProperty (GDK_WINDOW_XDISPLAY (window), 
-                  GDK_WINDOW_XWINDOW (window),
+  XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), 
+                  GDK_DRAWABLE_XID (window),
                   xdnd_aware_atom, XA_ATOM,
                   32, PropModeReplace,
                   (guchar *)&xdnd_version, 1);
diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c
new file mode 100644 (file)
index 0000000..c99de5b
--- /dev/null
@@ -0,0 +1,409 @@
+#include "gdkx.h"
+
+static void    gdk_x11_drawable_destroy   (GdkDrawable     *drawable);
+
+static void gdk_x11_draw_rectangle (GdkDrawable    *drawable,
+                                   GdkGC          *gc,
+                                   gint            filled,
+                                   gint            x,
+                                   gint            y,
+                                   gint            width,
+                                   gint            height);
+static void gdk_x11_draw_arc       (GdkDrawable    *drawable,
+                                   GdkGC          *gc,
+                                   gint            filled,
+                                   gint            x,
+                                   gint            y,
+                                   gint            width,
+                                   gint            height,
+                                   gint            angle1,
+                                   gint            angle2);
+static void gdk_x11_draw_polygon   (GdkDrawable    *drawable,
+                                   GdkGC          *gc,
+                                   gint            filled,
+                                   GdkPoint       *points,
+                                   gint            npoints);
+static void gdk_x11_draw_text      (GdkDrawable    *drawable,
+                                   GdkFont        *font,
+                                   GdkGC          *gc,
+                                   gint            x,
+                                   gint            y,
+                                   const gchar    *text,
+                                   gint            text_length);
+static void gdk_x11_draw_text_wc   (GdkDrawable    *drawable,
+                                   GdkFont        *font,
+                                   GdkGC          *gc,
+                                   gint            x,
+                                   gint            y,
+                                   const GdkWChar *text,
+                                   gint            text_length);
+static void gdk_x11_draw_drawable  (GdkDrawable    *drawable,
+                                   GdkGC          *gc,
+                                   GdkPixmap      *src,
+                                   gint            xsrc,
+                                   gint            ysrc,
+                                   gint            xdest,
+                                   gint            ydest,
+                                   gint            width,
+                                   gint            height);
+static void gdk_x11_draw_points    (GdkDrawable    *drawable,
+                                   GdkGC          *gc,
+                                   GdkPoint       *points,
+                                   gint            npoints);
+static void gdk_x11_draw_segments  (GdkDrawable    *drawable,
+                                   GdkGC          *gc,
+                                   GdkSegment     *segs,
+                                   gint            nsegs);
+static void gdk_x11_draw_lines     (GdkDrawable    *drawable,
+                                   GdkGC          *gc,
+                                   GdkPoint       *points,
+                                   gint            npoints);
+
+
+GdkDrawableClass _gdk_x11_drawable_class = {
+  gdk_x11_drawable_destroy,
+  _gdk_x11_gc_new,
+  gdk_x11_draw_rectangle,
+  gdk_x11_draw_arc,
+  gdk_x11_draw_polygon,
+  gdk_x11_draw_text,
+  gdk_x11_draw_text_wc,
+  gdk_x11_draw_drawable,
+  gdk_x11_draw_points,
+  gdk_x11_draw_segments,
+  gdk_x11_draw_lines
+};
+
+/*****************************************************
+ * X11 specific implementations of generic functions *
+ *****************************************************/
+
+GdkColormap*
+gdk_drawable_get_colormap (GdkDrawable *drawable)
+{
+  GdkDrawablePrivate *drawable_private;
+  XWindowAttributes window_attributes;
+  
+  g_return_val_if_fail (drawable != NULL, NULL);
+  drawable_private = (GdkDrawablePrivate*) drawable;
+  
+  if (!GDK_DRAWABLE_DESTROYED (drawable))
+    {
+      if (drawable_private->colormap == NULL &&
+         GDK_IS_WINDOW (drawable))
+       {
+         XGetWindowAttributes (GDK_DRAWABLE_XDISPLAY (drawable),
+                               GDK_DRAWABLE_XID (drawable),
+                               &window_attributes);
+         drawable_private->colormap =  gdk_colormap_lookup (window_attributes.colormap);
+       }
+
+      return drawable_private->colormap;
+    }
+  
+  return NULL;
+}
+
+void
+gdk_drawable_set_colormap (GdkDrawable *drawable,
+                          GdkColormap *colormap)
+{
+  GdkDrawablePrivate *drawable_private;
+  GdkColormapPrivateX *colormap_private;
+  
+  g_return_if_fail (drawable != NULL);
+  g_return_if_fail (colormap != NULL);
+  
+  drawable_private = (GdkDrawablePrivate *)drawable;
+  colormap_private = (GdkColormapPrivateX *)colormap;
+  
+  if (!GDK_DRAWABLE_DESTROYED (drawable))
+    {
+      if (GDK_IS_WINDOW (drawable))
+       {
+         g_return_if_fail (colormap_private->base.visual !=
+                           ((GdkColormapPrivate *)(drawable_private->colormap))->visual);
+
+         XSetWindowColormap (GDK_DRAWABLE_XDISPLAY (drawable),
+                             GDK_DRAWABLE_XID (drawable),
+                             colormap_private->xcolormap);
+       }
+
+      if (drawable_private->colormap)
+       gdk_colormap_unref (drawable_private->colormap);
+      drawable_private->colormap = colormap;
+      gdk_colormap_ref (drawable_private->colormap);
+
+      if (GDK_IS_WINDOW (drawable) &&
+         drawable_private->window_type != GDK_WINDOW_TOPLEVEL)
+       gdk_window_add_colormap_windows (drawable);
+    }
+}
+
+/* Drawing
+ */
+static void 
+gdk_x11_drawable_destroy (GdkDrawable *drawable)
+{
+  
+}
+
+static void
+gdk_x11_draw_rectangle (GdkDrawable *drawable,
+                       GdkGC       *gc,
+                       gint         filled,
+                       gint         x,
+                       gint         y,
+                       gint         width,
+                       gint         height)
+{
+  if (filled)
+    XFillRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                   GDK_GC_XGC (gc), x, y, width, height);
+  else
+    XDrawRectangle (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                   GDK_GC_XGC (gc), x, y, width, height);
+}
+
+static void
+gdk_x11_draw_arc (GdkDrawable *drawable,
+                 GdkGC       *gc,
+                 gint         filled,
+                 gint         x,
+                 gint         y,
+                 gint         width,
+                 gint         height,
+                 gint         angle1,
+                 gint         angle2)
+{
+  if (filled)
+    XFillArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+             GDK_GC_XGC (gc), x, y, width, height, angle1, angle2);
+  else
+    XDrawArc (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+             GDK_GC_XGC (gc), x, y, width, height, angle1, angle2);
+}
+
+static void
+gdk_x11_draw_polygon (GdkDrawable *drawable,
+                     GdkGC       *gc,
+                     gint         filled,
+                     GdkPoint    *points,
+                     gint         npoints)
+{
+  if (filled)
+    {
+      XFillPolygon (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                   GDK_GC_XGC (gc), (XPoint*) points, npoints, Complex, CoordModeOrigin);
+    }
+  else
+    {
+      GdkPoint *local_points = points;
+      gint local_npoints = npoints;
+      gint local_alloc = 0;
+
+      if ((points[0].x != points[npoints-1].x) ||
+        (points[0].y != points[npoints-1].y)) 
+        {
+          local_alloc = 1;
+          ++local_npoints;
+          local_points = (GdkPoint*) g_malloc (local_npoints * sizeof(GdkPoint));
+          memcpy (local_points, points, npoints * sizeof(GdkPoint));
+          local_points[npoints].x = points[0].x;
+          local_points[npoints].y = points[0].y;
+      }
+
+      XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                 GDK_GC_XGC (gc),
+                 (XPoint*) local_points, local_npoints,
+                 CoordModeOrigin);
+  
+       if (local_alloc)
+       g_free (local_points);
+    }
+}
+
+/* gdk_x11_draw_text
+ *
+ * Modified by Li-Da Lho to draw 16 bits and Multibyte strings
+ *
+ * Interface changed: add "GdkFont *font" to specify font or fontset explicitely
+ */
+static void
+gdk_x11_draw_text (GdkDrawable *drawable,
+                  GdkFont     *font,
+                  GdkGC       *gc,
+                  gint         x,
+                  gint         y,
+                  const gchar *text,
+                  gint         text_length)
+{
+  if (font->type == GDK_FONT_FONT)
+    {
+      XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font);
+      XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), GDK_GC_XGC (gc), xfont->fid);
+      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
+       {
+         XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                      GDK_GC_XGC (gc), x, y, text, text_length);
+       }
+      else
+       {
+         XDrawString16 (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                        GDK_GC_XGC (gc), x, y, (XChar2b *) text, text_length / 2);
+       }
+    }
+  else if (font->type == GDK_FONT_FONTSET)
+    {
+      XFontSet fontset = (XFontSet) GDK_FONT_XFONT (font);
+      XmbDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                    fontset, GDK_GC_XGC (gc), x, y, text, text_length);
+    }
+  else
+    g_error("undefined font type\n");
+}
+
+static void
+gdk_x11_draw_text_wc (GdkDrawable    *drawable,
+                     GdkFont        *font,
+                     GdkGC          *gc,
+                     gint            x,
+                     gint            y,
+                     const GdkWChar *text,
+                     gint            text_length)
+{
+  if (font->type == GDK_FONT_FONT)
+    {
+      XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font);
+      gchar *text_8bit;
+      gint i;
+      XSetFont(GDK_DRAWABLE_XDISPLAY (drawable), GDK_GC_XGC (gc), xfont->fid);
+      text_8bit = g_new (gchar, text_length);
+      for (i=0; i<text_length; i++) text_8bit[i] = text[i];
+      XDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                   GDK_GC_XGC (gc), x, y, text_8bit, text_length);
+      g_free (text_8bit);
+    }
+  else if (font->type == GDK_FONT_FONTSET)
+    {
+      if (sizeof(GdkWChar) == sizeof(wchar_t))
+       {
+         XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                        (XFontSet) GDK_FONT_XFONT (font),
+                        GDK_GC_XGC (gc), x, y, (wchar_t *)text, text_length);
+       }
+      else
+       {
+         wchar_t *text_wchar;
+         gint i;
+         text_wchar = g_new (wchar_t, text_length);
+         for (i=0; i<text_length; i++) text_wchar[i] = text[i];
+         XwcDrawString (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                        (XFontSet) GDK_FONT_XFONT (font),
+                        GDK_GC_XGC (gc), x, y, text_wchar, text_length);
+         g_free (text_wchar);
+       }
+    }
+  else
+    g_error("undefined font type\n");
+}
+
+static void
+gdk_x11_draw_drawable (GdkDrawable *drawable,
+                      GdkGC       *gc,
+                      GdkPixmap   *src,
+                      gint         xsrc,
+                      gint         ysrc,
+                      gint         xdest,
+                      gint         ydest,
+                      gint         width,
+                      gint         height)
+{
+  /* FIXME: this doesn't work because bitmaps don't have visuals */
+  if (gdk_drawable_get_visual (src)->depth == 1)
+    {
+      XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable),
+                GDK_DRAWABLE_XID (src),
+                GDK_DRAWABLE_XID (drawable),
+                GDK_GC_XGC (gc),
+                xsrc, ysrc,
+                width, height,
+                xdest, ydest);
+    }
+  else
+    {
+      XCopyArea (GDK_DRAWABLE_XDISPLAY (drawable),
+                GDK_DRAWABLE_XID (src),
+                GDK_DRAWABLE_XID (drawable),
+                GDK_GC_XGC (gc),
+                xsrc, ysrc,
+                width, height,
+                xdest, ydest);
+    }
+}
+
+static void
+gdk_x11_draw_points (GdkDrawable *drawable,
+                    GdkGC       *gc,
+                    GdkPoint    *points,
+                    gint         npoints)
+{
+  /* We special-case npoints == 1, because X will merge multiple
+   * consecutive XDrawPoint requests into a PolyPoint request
+   */
+  if (npoints == 1)
+    {
+      XDrawPoint (GDK_DRAWABLE_XDISPLAY (drawable),
+                 GDK_DRAWABLE_XID (drawable),
+                 GDK_GC_XGC (gc),
+                 points[0].x, points[0].y);
+    }
+  else
+    {
+      XDrawPoints (GDK_DRAWABLE_XDISPLAY (drawable),
+                  GDK_DRAWABLE_XID (drawable),
+                  GDK_GC_XGC (gc),
+                  (XPoint *) points,
+                  npoints,
+                  CoordModeOrigin);
+    }
+}
+
+static void
+gdk_x11_draw_segments (GdkDrawable *drawable,
+                      GdkGC       *gc,
+                      GdkSegment  *segs,
+                      gint         nsegs)
+{
+  /* We special-case nsegs == 1, because X will merge multiple
+   * consecutive XDrawLine requests into a PolySegment request
+   */
+  if (nsegs == 1)
+    {
+      XDrawLine (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable),
+                GDK_GC_XGC (gc), segs[0].x1, segs[0].y1,
+                segs[0].x2, segs[0].y2);
+    }
+  else
+    {
+      XDrawSegments (GDK_DRAWABLE_XDISPLAY (drawable),
+                    GDK_DRAWABLE_XID (drawable),
+                    GDK_GC_XGC (gc),
+                    (XSegment *) segs,
+                    nsegs);
+    }
+}
+
+static void
+gdk_x11_draw_lines (GdkDrawable *drawable,
+                   GdkGC       *gc,
+                   GdkPoint    *points,
+                   gint         npoints)
+{
+  XDrawLines (GDK_DRAWABLE_XDISPLAY (drawable),
+             GDK_DRAWABLE_XID (drawable),
+             GDK_GC_XGC (gc),
+             (XPoint *) points,
+             npoints,
+             CoordModeOrigin);
+}
index 1738a0dbbeb29f209dc9543372a13d6737e64ff7..c15fe8ce2bdb16eb6f67a992f678b3c9a3cd2f0a 100644 (file)
@@ -73,7 +73,6 @@ struct _GdkEventPrivate
  * Private function declarations
  */
 
-static GdkEvent *gdk_event_new         (void);
 static gint     gdk_event_apply_filters (XEvent   *xevent,
                                          GdkEvent *event,
                                          GList    *filters);
@@ -84,8 +83,6 @@ static Bool    gdk_event_get_type     (Display   *display,
                                         XEvent    *xevent, 
                                         XPointer   arg);
 #endif
-static void      gdk_events_queue       (void);
-static GdkEvent* gdk_event_unqueue      (void);
 
 static gboolean  gdk_event_prepare      (gpointer   source_data, 
                                         GTimeVal  *current_time,
@@ -98,9 +95,6 @@ static gboolean  gdk_event_dispatch     (gpointer   source_data,
                                         GTimeVal  *current_time,
                                         gpointer   user_data);
 
-static void     gdk_synthesize_click   (GdkEvent  *event, 
-                                        gint       nclicks);
-
 GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
                                         GdkEvent  *event,
                                         gpointer   data);
@@ -114,28 +108,8 @@ static int connection_number = 0;      /* The file descriptor number of our
                                             *  when events are pending by using
                                             *  the "select" system call.
                                             */
-static guint32 button_click_time[2];       /* The last 2 button click times. Used
-                                            *  to determine if the latest button click
-                                            *  is part of a double or triple click.
-                                            */
-static GdkWindow *button_window[2];        /* The last 2 windows to receive button presses.
-                                            *  Also used to determine if the latest button
-                                            *  click is part of a double or triple click.
-                                            */
-static guint button_number[2];             /* The last 2 buttons to be pressed.
-                                            */
-static GdkEventFunc   event_func = NULL;    /* Callback for events */
-static gpointer       event_data = NULL;
-static GDestroyNotify event_notify = NULL;
-
 static GList *client_filters;              /* Filters for client messages */
 
-/* FIFO's for event queue, and for events put back using
- * gdk_event_put().
- */
-static GList *queued_events = NULL;
-static GList *queued_tail = NULL;
-
 static GSourceFuncs event_funcs = {
   gdk_event_prepare,
   gdk_event_check,
@@ -149,75 +123,6 @@ GPollFD event_poll_fd;
  * Functions for maintaining the event queue *
  *********************************************/
 
-/*************************************************************
- * gdk_event_queue_find_first:
- *     Find the first event on the queue that is not still
- *     being filled in.
- *   arguments:
- *     
- *   results:
- *     Pointer to the list node for that event, or NULL
- *************************************************************/
-
-static GList*
-gdk_event_queue_find_first (void)
-{
-  GList *tmp_list = queued_events;
-
-  while (tmp_list)
-    {
-      GdkEventPrivate *event = tmp_list->data;
-      if (!(event->flags & GDK_EVENT_PENDING))
-       return tmp_list;
-
-      tmp_list = g_list_next (tmp_list);
-    }
-
-  return NULL;
-}
-
-/*************************************************************
- * gdk_event_queue_remove_link:
- *     Remove a specified list node from the event queue.
- *   arguments:
- *     node: Node to remove.
- *   results:
- *************************************************************/
-
-static void
-gdk_event_queue_remove_link (GList *node)
-{
-  if (node->prev)
-    node->prev->next = node->next;
-  else
-    queued_events = node->next;
-  
-  if (node->next)
-    node->next->prev = node->prev;
-  else
-    queued_tail = node->prev;
-  
-}
-
-/*************************************************************
- * gdk_event_queue_append:
- *     Append an event onto the tail of the event queue.
- *   arguments:
- *     event: Event to append.
- *   results:
- *************************************************************/
-
-static void
-gdk_event_queue_append (GdkEvent *event)
-{
-  queued_tail = g_list_append (queued_tail, event);
-  
-  if (!queued_events)
-    queued_events = queued_tail;
-  else
-    queued_tail = queued_tail->next;
-}
-
 void 
 gdk_events_init (void)
 {
@@ -232,13 +137,6 @@ gdk_events_init (void)
   
   g_main_add_poll (&event_poll_fd, GDK_PRIORITY_EVENTS);
 
-  button_click_time[0] = 0;
-  button_click_time[1] = 0;
-  button_window[0] = NULL;
-  button_window[1] = NULL;
-  button_number[0] = -1;
-  button_number[1] = -1;
-
   gdk_add_client_message_filter (gdk_wm_protocols, 
                                 gdk_wm_protocols_filter, NULL);
 }
@@ -525,410 +423,6 @@ gdk_compress_exposures (XEvent    *xevent,
   xevent->xexpose.height = rect1.height;
 }
 
-/*************************************************************
- * gdk_event_handler_set:
- *     
- *   arguments:
- *     func: Callback function to be called for each event.
- *     data: Data supplied to the function
- *     notify: function called when function is no longer needed
- * 
- *   results:
- *************************************************************/
-
-void 
-gdk_event_handler_set (GdkEventFunc   func,
-                      gpointer       data,
-                      GDestroyNotify notify)
-{
-  if (event_notify)
-    (*event_notify) (event_data);
-
-  event_func = func;
-  event_data = data;
-  event_notify = notify;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_event_get
- *
- *   Gets the next event.
- *
- * Arguments:
- *
- * Results:
- *   If an event is waiting that we care about, returns 
- *   a pointer to that event, to be freed with gdk_event_free.
- *   Otherwise, returns NULL.
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-GdkEvent*
-gdk_event_get (void)
-{
-  gdk_events_queue ();
-
-  return gdk_event_unqueue ();
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_event_peek
- *
- *   Gets the next event.
- *
- * Arguments:
- *
- * Results:
- *   If an event is waiting that we care about, returns 
- *   a copy of that event, but does not remove it from
- *   the queue. The pointer is to be freed with gdk_event_free.
- *   Otherwise, returns NULL.
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-GdkEvent*
-gdk_event_peek (void)
-{
-  GList *tmp_list;
-
-  tmp_list = gdk_event_queue_find_first ();
-  
-  if (tmp_list)
-    return gdk_event_copy (tmp_list->data);
-  else
-    return NULL;
-}
-
-void
-gdk_event_put (GdkEvent *event)
-{
-  GdkEvent *new_event;
-  
-  g_return_if_fail (event != NULL);
-  
-  new_event = gdk_event_copy (event);
-
-  gdk_event_queue_append (new_event);
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_event_copy
- *
- *   Copy a event structure into new storage.
- *
- * Arguments:
- *   "event" is the event struct to copy.
- *
- * Results:
- *   A new event structure.  Free it with gdk_event_free.
- *
- * Side effects:
- *   The reference count of the window in the event is increased.
- *
- *--------------------------------------------------------------
- */
-
-static GMemChunk *event_chunk = NULL;
-
-static GdkEvent*
-gdk_event_new (void)
-{
-  GdkEventPrivate *new_event;
-  
-  if (event_chunk == NULL)
-    event_chunk = g_mem_chunk_new ("events",
-                                  sizeof (GdkEventPrivate),
-                                  4096,
-                                  G_ALLOC_AND_FREE);
-  
-  new_event = g_chunk_new (GdkEventPrivate, event_chunk);
-  new_event->flags = 0;
-  
-  return (GdkEvent*) new_event;
-}
-
-GdkEvent*
-gdk_event_copy (GdkEvent *event)
-{
-  GdkEvent *new_event;
-  
-  g_return_val_if_fail (event != NULL, NULL);
-  
-  new_event = gdk_event_new ();
-  
-  *new_event = *event;
-  gdk_window_ref (new_event->any.window);
-  
-  switch (event->any.type)
-    {
-    case GDK_KEY_PRESS:
-    case GDK_KEY_RELEASE:
-      new_event->key.string = g_strdup (event->key.string);
-      break;
-      
-    case GDK_ENTER_NOTIFY:
-    case GDK_LEAVE_NOTIFY:
-      if (event->crossing.subwindow != NULL)
-       gdk_window_ref (event->crossing.subwindow);
-      break;
-      
-    case GDK_DRAG_ENTER:
-    case GDK_DRAG_LEAVE:
-    case GDK_DRAG_MOTION:
-    case GDK_DRAG_STATUS:
-    case GDK_DROP_START:
-    case GDK_DROP_FINISHED:
-      gdk_drag_context_ref (event->dnd.context);
-      break;
-      
-    default:
-      break;
-    }
-  
-  return new_event;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_event_free
- *
- *   Free a event structure obtained from gdk_event_copy.  Do not use
- *   with other event structures.
- *
- * Arguments:
- *   "event" is the event struct to free.
- *
- * Results:
- *
- * Side effects:
- *   The reference count of the window in the event is decreased and
- *   might be freed, too.
- *
- *-------------------------------------------------------------- */
-
-void
-gdk_event_free (GdkEvent *event)
-{
-  g_return_if_fail (event != NULL);
-
-  g_assert (event_chunk != NULL); /* paranoid */
-  
-  if (event->any.window)
-    gdk_window_unref (event->any.window);
-  
-  switch (event->any.type)
-    {
-    case GDK_KEY_PRESS:
-    case GDK_KEY_RELEASE:
-      g_free (event->key.string);
-      break;
-      
-    case GDK_ENTER_NOTIFY:
-    case GDK_LEAVE_NOTIFY:
-      if (event->crossing.subwindow != NULL)
-       gdk_window_unref (event->crossing.subwindow);
-      break;
-      
-    case GDK_DRAG_ENTER:
-    case GDK_DRAG_LEAVE:
-    case GDK_DRAG_MOTION:
-    case GDK_DRAG_STATUS:
-    case GDK_DROP_START:
-    case GDK_DROP_FINISHED:
-      gdk_drag_context_unref (event->dnd.context);
-      break;
-      
-    default:
-      break;
-    }
-  
-  g_mem_chunk_free (event_chunk, event);
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_event_get_time:
- *    Get the timestamp from an event.
- *   arguments:
- *     event:
- *   results:
- *    The event's time stamp, if it has one, otherwise
- *    GDK_CURRENT_TIME.
- *--------------------------------------------------------------
- */
-
-guint32
-gdk_event_get_time (GdkEvent *event)
-{
-  if (event)
-    switch (event->type)
-      {
-      case GDK_MOTION_NOTIFY:
-       return event->motion.time;
-      case GDK_BUTTON_PRESS:
-      case GDK_2BUTTON_PRESS:
-      case GDK_3BUTTON_PRESS:
-      case GDK_BUTTON_RELEASE:
-       return event->button.time;
-      case GDK_KEY_PRESS:
-      case GDK_KEY_RELEASE:
-       return event->key.time;
-      case GDK_ENTER_NOTIFY:
-      case GDK_LEAVE_NOTIFY:
-       return event->crossing.time;
-      case GDK_PROPERTY_NOTIFY:
-       return event->property.time;
-      case GDK_SELECTION_CLEAR:
-      case GDK_SELECTION_REQUEST:
-      case GDK_SELECTION_NOTIFY:
-       return event->selection.time;
-      case GDK_PROXIMITY_IN:
-      case GDK_PROXIMITY_OUT:
-       return event->proximity.time;
-      case GDK_DRAG_ENTER:
-      case GDK_DRAG_LEAVE:
-      case GDK_DRAG_MOTION:
-      case GDK_DRAG_STATUS:
-      case GDK_DROP_START:
-      case GDK_DROP_FINISHED:
-       return event->dnd.time;
-      default:                 /* use current time */
-       break;
-      }
-  
-  return GDK_CURRENT_TIME;
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_set_show_events
- *
- *   Turns on/off the showing of events.
- *
- * Arguments:
- *   "show_events" is a boolean describing whether or
- *   not to show the events gdk receives.
- *
- * Results:
- *
- * Side effects:
- *   When "show_events" is TRUE, calls to "gdk_event_get"
- *   will output debugging informatin regarding the event
- *   received to stdout.
- *
- *--------------------------------------------------------------
- */
-
-void
-gdk_set_show_events (gint show_events)
-{
-  if (show_events)
-    gdk_debug_flags |= GDK_DEBUG_EVENTS;
-  else
-    gdk_debug_flags &= ~GDK_DEBUG_EVENTS;
-}
-
-gint
-gdk_get_show_events (void)
-{
-  return gdk_debug_flags & GDK_DEBUG_EVENTS;
-}
-
-static void
-gdk_io_destroy (gpointer data)
-{
-  GdkIOClosure *closure = data;
-
-  if (closure->notify)
-    closure->notify (closure->data);
-
-  g_free (closure);
-}
-
-/* What do we do with G_IO_NVAL?
- */
-#define READ_CONDITION (G_IO_IN | G_IO_HUP | G_IO_ERR)
-#define WRITE_CONDITION (G_IO_OUT | G_IO_ERR)
-#define EXCEPTION_CONDITION (G_IO_PRI)
-
-static gboolean  
-gdk_io_invoke (GIOChannel   *source,
-              GIOCondition  condition,
-              gpointer      data)
-{
-  GdkIOClosure *closure = data;
-  GdkInputCondition gdk_cond = 0;
-
-  if (condition & READ_CONDITION)
-    gdk_cond |= GDK_INPUT_READ;
-  if (condition & WRITE_CONDITION)
-    gdk_cond |= GDK_INPUT_WRITE;
-  if (condition & EXCEPTION_CONDITION)
-    gdk_cond |= GDK_INPUT_EXCEPTION;
-
-  if (closure->condition & gdk_cond)
-    closure->function (closure->data, g_io_channel_unix_get_fd (source), gdk_cond);
-
-  return TRUE;
-}
-
-gint
-gdk_input_add_full (gint             source,
-                   GdkInputCondition condition,
-                   GdkInputFunction  function,
-                   gpointer          data,
-                   GdkDestroyNotify  destroy)
-{
-  guint result;
-  GdkIOClosure *closure = g_new (GdkIOClosure, 1);
-  GIOChannel *channel;
-  GIOCondition cond = 0;
-
-  closure->function = function;
-  closure->condition = condition;
-  closure->notify = destroy;
-  closure->data = data;
-
-  if (condition & GDK_INPUT_READ)
-    cond |= READ_CONDITION;
-  if (condition & GDK_INPUT_WRITE)
-    cond |= WRITE_CONDITION;
-  if (condition & GDK_INPUT_EXCEPTION)
-    cond |= EXCEPTION_CONDITION;
-
-  channel = g_io_channel_unix_new (source);
-  result = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, cond, 
-                               gdk_io_invoke,
-                               closure, gdk_io_destroy);
-  g_io_channel_unref (channel);
-
-  return result;
-}
-
-gint
-gdk_input_add (gint             source,
-              GdkInputCondition condition,
-              GdkInputFunction  function,
-              gpointer          data)
-{
-  return gdk_input_add_full (source, condition, function, data, NULL);
-}
-
-void
-gdk_input_remove (gint tag)
-{
-  g_source_remove (tag);
-}
-
 static gint
 gdk_event_apply_filters (XEvent *xevent,
                         GdkEvent *event,
@@ -1220,43 +714,9 @@ gdk_event_translate (GdkEvent *event,
       event->button.button = xevent->xbutton.button;
       event->button.source = GDK_SOURCE_MOUSE;
       event->button.deviceid = GDK_CORE_POINTER;
-      
-      if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) &&
-         (event->button.window == button_window[1]) &&
-         (event->button.button == button_number[1]))
-       {
-         gdk_synthesize_click (event, 3);
-         
-         button_click_time[1] = 0;
-         button_click_time[0] = 0;
-         button_window[1] = NULL;
-         button_window[0] = 0;
-         button_number[1] = -1;
-         button_number[0] = -1;
-       }
-      else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) &&
-              (event->button.window == button_window[0]) &&
-              (event->button.button == button_number[0]))
-       {
-         gdk_synthesize_click (event, 2);
-         
-         button_click_time[1] = button_click_time[0];
-         button_click_time[0] = event->button.time;
-         button_window[1] = button_window[0];
-         button_window[0] = event->button.window;
-         button_number[1] = button_number[0];
-         button_number[0] = event->button.button;
-       }
-      else
-       {
-         button_click_time[1] = 0;
-         button_click_time[0] = event->button.time;
-         button_window[1] = NULL;
-         button_window[0] = event->button.window;
-         button_number[1] = -1;
-         button_number[0] = event->button.button;
-       }
 
+      gdk_event_button_generate (event);
+      
       break;
       
     case ButtonRelease:
@@ -1972,7 +1432,7 @@ gdk_event_get_type (Display  *display,
 }
 #endif
 
-static void
+void
 gdk_events_queue (void)
 {
   GList *node;
@@ -2011,7 +1471,7 @@ gdk_events_queue (void)
       ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
 
       gdk_event_queue_append (event);
-      node = queued_tail;
+      node = gdk_queued_tail;
 
       if (gdk_event_translate (event, &xevent))
        {
@@ -2064,24 +1524,6 @@ gdk_event_check (gpointer  source_data,
   return retval;
 }
 
-static GdkEvent*
-gdk_event_unqueue (void)
-{
-  GdkEvent *event = NULL;
-  GList *tmp_list;
-
-  tmp_list = gdk_event_queue_find_first ();
-
-  if (tmp_list)
-    {
-      event = tmp_list->data;
-      gdk_event_queue_remove_link (tmp_list);
-      g_list_free_1 (tmp_list);
-    }
-
-  return event;
-}
-
 static gboolean  
 gdk_event_dispatch (gpointer  source_data,
                    GTimeVal *current_time,
@@ -2096,8 +1538,8 @@ gdk_event_dispatch (gpointer  source_data,
 
   if (event)
     {
-      if (event_func)
-       (*event_func) (event, event_data);
+      if (gdk_event_func)
+       (*gdk_event_func) (event, gdk_event_data);
       
       gdk_event_free (event);
     }
@@ -2107,20 +1549,6 @@ gdk_event_dispatch (gpointer  source_data,
   return TRUE;
 }
 
-static void
-gdk_synthesize_click (GdkEvent *event,
-                     gint      nclicks)
-{
-  GdkEvent temp_event;
-  
-  g_return_if_fail (event != NULL);
-  
-  temp_event = *event;
-  temp_event.type = (nclicks == 2) ? GDK_2BUTTON_PRESS : GDK_3BUTTON_PRESS;
-  
-  gdk_event_put (&temp_event);
-}
-
 /* Sends a ClientMessage to all toplevel client windows */
 gboolean
 gdk_event_send_client_message (GdkEvent *event, guint32 xid)
index a3a3502fba28590e4ef3434850088c0feee6d242..55b4524fcedb1c57d5103bf55272d9587f602e90 100644 (file)
@@ -27,7 +27,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xos.h>
 #include "gdkfont.h"
-#include "gdkprivate.h"
+#include "gdkx.h"
 
 static GHashTable *font_name_hash = NULL;
 static GHashTable *fontset_name_hash = NULL;
@@ -35,7 +35,7 @@ static GHashTable *fontset_name_hash = NULL;
 static void
 gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
 {
-  GdkFontPrivate *private = (GdkFontPrivate *)font;
+  GdkFontPrivateX *private = (GdkFontPrivateX *)font;
   GHashTable **hashp = (type == GDK_FONT_FONT) ?
     &font_name_hash : &fontset_name_hash;
 
@@ -49,7 +49,7 @@ gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
 static void
 gdk_font_hash_remove (GdkFontType type, GdkFont *font)
 {
-  GdkFontPrivate *private = (GdkFontPrivate *)font;
+  GdkFontPrivateX *private = (GdkFontPrivateX *)font;
   GSList *tmp_list;
   GHashTable *hash = (type == GDK_FONT_FONT) ?
     font_name_hash : fontset_name_hash;
@@ -90,7 +90,7 @@ GdkFont*
 gdk_font_load (const gchar *font_name)
 {
   GdkFont *font;
-  GdkFontPrivate *private;
+  GdkFontPrivateX *private;
   XFontStruct *xfont;
 
   g_return_val_if_fail (font_name != NULL, NULL);
@@ -106,7 +106,7 @@ gdk_font_load (const gchar *font_name)
   font = gdk_font_lookup (xfont->fid);
   if (font != NULL)
     {
-      private = (GdkFontPrivate *) font;
+      private = (GdkFontPrivateX *) font;
       if (xfont != private->xfont)
        XFreeFont (gdk_display, xfont);
 
@@ -114,10 +114,10 @@ gdk_font_load (const gchar *font_name)
     }
   else
     {
-      private = g_new (GdkFontPrivate, 1);
+      private = g_new (GdkFontPrivateX, 1);
       private->xdisplay = gdk_display;
       private->xfont = xfont;
-      private->ref_count = 1;
+      private->base.ref_count = 1;
       private->names = NULL;
  
       font = (GdkFont*) private;
@@ -137,7 +137,7 @@ GdkFont*
 gdk_fontset_load (gchar *fontset_name)
 {
   GdkFont *font;
-  GdkFontPrivate *private;
+  GdkFontPrivateX *private;
   XFontSet fontset;
   gint  missing_charset_count;
   gchar **missing_charset_list;
@@ -147,7 +147,7 @@ gdk_fontset_load (gchar *fontset_name)
   if (font)
     return font;
 
-  private = g_new (GdkFontPrivate, 1);
+  private = g_new (GdkFontPrivateX, 1);
   font = (GdkFont*) private;
 
   private->xdisplay = gdk_display;
@@ -164,7 +164,7 @@ gdk_fontset_load (gchar *fontset_name)
       XFreeStringList (missing_charset_list);
     }
 
-  private->ref_count = 1;
+  private->base.ref_count = 1;
 
   if (!fontset)
     {
@@ -197,57 +197,74 @@ gdk_fontset_load (gchar *fontset_name)
     }
 }
 
-GdkFont*
-gdk_font_ref (GdkFont *font)
+void
+_gdk_font_destroy (GdkFont *font)
 {
-  GdkFontPrivate *private;
-
-  g_return_val_if_fail (font != NULL, NULL);
-
-  private = (GdkFontPrivate*) font;
-  private->ref_count += 1;
-  return font;
+  GdkFontPrivateX *private = (GdkFontPrivateX *)font;
+  
+  gdk_font_hash_remove (font->type, font);
+      
+  switch (font->type)
+    {
+    case GDK_FONT_FONT:
+      gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
+      XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
+      break;
+    case GDK_FONT_FONTSET:
+      XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
+      break;
+    default:
+      g_error ("unknown font type.");
+      break;
+    }
+  g_free (font);
 }
 
-void
-gdk_font_unref (GdkFont *font)
+gint
+_gdk_font_strlen (GdkFont     *font,
+                 const gchar *str)
 {
-  GdkFontPrivate *private;
-  private = (GdkFontPrivate*) font;
+  GdkFontPrivateX *font_private;
+  gint length = 0;
 
-  g_return_if_fail (font != NULL);
-  g_return_if_fail (private->ref_count > 0);
+  g_return_val_if_fail (font != NULL, -1);
+  g_return_val_if_fail (str != NULL, -1);
 
-  private->ref_count -= 1;
-  if (private->ref_count == 0)
+  font_private = (GdkFontPrivateX*) font;
+
+  if (font->type == GDK_FONT_FONT)
     {
-      gdk_font_hash_remove (font->type, font);
-      
-      switch (font->type)
+      XFontStruct *xfont = (XFontStruct *) font_private->xfont;
+      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
        {
-       case GDK_FONT_FONT:
-         gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
-         XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
-         break;
-       case GDK_FONT_FONTSET:
-         XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
-         break;
-       default:
-         g_error ("unknown font type.");
-         break;
+         length = strlen (str);
        }
-      g_free (font);
+      else
+       {
+         guint16 *string_2b = (guint16 *)str;
+           
+         while (*(string_2b++))
+           length++;
+       }
+    }
+  else if (font->type == GDK_FONT_FONTSET)
+    {
+      length = strlen (str);
     }
+  else
+    g_error("undefined font type\n");
+
+  return length;
 }
 
 gint
 gdk_font_id (const GdkFont *font)
 {
-  const GdkFontPrivate *font_private;
+  const GdkFontPrivateX *font_private;
 
   g_return_val_if_fail (font != NULL, 0);
 
-  font_private = (const GdkFontPrivate*) font;
+  font_private = (const GdkFontPrivateX*) font;
 
   if (font->type == GDK_FONT_FONT)
     {
@@ -263,14 +280,14 @@ gint
 gdk_font_equal (const GdkFont *fonta,
                 const GdkFont *fontb)
 {
-  const GdkFontPrivate *privatea;
-  const GdkFontPrivate *privateb;
+  const GdkFontPrivateX *privatea;
+  const GdkFontPrivateX *privateb;
 
   g_return_val_if_fail (fonta != NULL, FALSE);
   g_return_val_if_fail (fontb != NULL, FALSE);
 
-  privatea = (const GdkFontPrivate*) fonta;
-  privateb = (const GdkFontPrivate*) fontb;
+  privatea = (const GdkFontPrivateX*) fonta;
+  privateb = (const GdkFontPrivateX*) fontb;
 
   if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)
     {
@@ -291,50 +308,12 @@ gdk_font_equal (const GdkFont *fonta,
     return 0;
 }
 
-gint
-gdk_string_width (GdkFont     *font,
-                 const gchar *string)
-{
-  GdkFontPrivate *font_private;
-  gint width;
-  XFontStruct *xfont;
-  XFontSet fontset;
-
-  g_return_val_if_fail (font != NULL, -1);
-  g_return_val_if_fail (string != NULL, -1);
-
-  font_private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) font_private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         width = XTextWidth (xfont, string, strlen (string));
-       }
-      else
-       {
-         width = XTextWidth16 (xfont, (XChar2b *) string, strlen (string) / 2);
-       }
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) font_private->xfont;
-      width = XmbTextEscapement (fontset, string, strlen(string));
-      break;
-    default:
-      width = 0;
-    }
-
-  return width;
-}
-
 gint
 gdk_text_width (GdkFont      *font,
                const gchar  *text,
                gint          text_length)
 {
-  GdkFontPrivate *private;
+  GdkFontPrivateX *private;
   gint width;
   XFontStruct *xfont;
   XFontSet fontset;
@@ -342,7 +321,7 @@ gdk_text_width (GdkFont      *font,
   g_return_val_if_fail (font != NULL, -1);
   g_return_val_if_fail (text != NULL, -1);
 
-  private = (GdkFontPrivate*) font;
+  private = (GdkFontPrivateX*) font;
 
   switch (font->type)
     {
@@ -372,7 +351,7 @@ gdk_text_width_wc (GdkFont    *font,
                   const GdkWChar *text,
                   gint            text_length)
 {
-  GdkFontPrivate *private;
+  GdkFontPrivateX *private;
   gint width;
   XFontStruct *xfont;
   XFontSet fontset;
@@ -380,7 +359,7 @@ gdk_text_width_wc (GdkFont    *font,
   g_return_val_if_fail (font != NULL, -1);
   g_return_val_if_fail (text != NULL, -1);
 
-  private = (GdkFontPrivate*) font;
+  private = (GdkFontPrivateX*) font;
 
   switch (font->type)
     {
@@ -423,113 +402,6 @@ gdk_text_width_wc (GdkFont          *font,
   return width;
 }
 
-/* Problem: What if a character is a 16 bits character ?? */
-gint
-gdk_char_width (GdkFont *font,
-               gchar    character)
-{
-  GdkFontPrivate *private;
-  XCharStruct *chars;
-  gint width;
-  guint ch = character & 0xff;  /* get rid of sign-extension */
-  XFontStruct *xfont;
-  XFontSet fontset;
-
-  g_return_val_if_fail (font != NULL, -1);
-
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      /* only 8 bits characters are considered here */
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) &&
-         (xfont->max_byte1 == 0) &&
-         (ch >= xfont->min_char_or_byte2) &&
-         (ch <= xfont->max_char_or_byte2))
-       {
-         chars = xfont->per_char;
-         if (chars)
-           width = chars[ch - xfont->min_char_or_byte2].width;
-         else
-           width = xfont->min_bounds.width;
-       }
-      else
-       {
-         width = XTextWidth (xfont, &character, 1);
-       }
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      width = XmbTextEscapement (fontset, &character, 1) ;
-      break;
-    default:
-      width = 0;
-    }
-  return width;
-}
-
-gint
-gdk_char_width_wc (GdkFont *font,
-                  GdkWChar character)
-{
-  GdkFontPrivate *private;
-  XCharStruct *chars;
-  gint width;
-  guint ch = character & 0xff;  /* get rid of sign-extension */
-  XFontStruct *xfont;
-  XFontSet fontset;
-
-  g_return_val_if_fail (font != NULL, -1);
-
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      /* only 8 bits characters are considered here */
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) &&
-          (xfont->max_byte1 == 0) &&
-          (ch >= xfont->min_char_or_byte2) &&
-          (ch <= xfont->max_char_or_byte2))
-        {
-          chars = xfont->per_char;
-          if (chars)
-            width = chars[ch - xfont->min_char_or_byte2].width;
-          else
-            width = xfont->min_bounds.width;
-        }
-      else
-        {
-          char ch2 = character;
-          width = XTextWidth (xfont, &ch2, 1);
-        }
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      {
-       wchar_t char_wc = character;
-        width = XwcTextEscapement (fontset, &char_wc, 1) ;
-      }
-      break;
-    default:
-      width = 0;
-    }
-  return width;
-}
-
-gint
-gdk_string_measure (GdkFont     *font,
-                    const gchar *string)
-{
-  g_return_val_if_fail (font != NULL, -1);
-  g_return_val_if_fail (string != NULL, -1);
-
-  return gdk_text_measure (font, string, strlen (string));
-}
-
 void
 gdk_text_extents (GdkFont     *font,
                   const gchar *text,
@@ -540,7 +412,7 @@ gdk_text_extents (GdkFont     *font,
                  gint        *ascent,
                  gint        *descent)
 {
-  GdkFontPrivate *private;
+  GdkFontPrivateX *private;
   XCharStruct overall;
   XFontStruct *xfont;
   XFontSet    fontset;
@@ -552,7 +424,7 @@ gdk_text_extents (GdkFont     *font,
   g_return_if_fail (font != NULL);
   g_return_if_fail (text != NULL);
 
-  private = (GdkFontPrivate*) font;
+  private = (GdkFontPrivateX*) font;
 
   switch (font->type)
     {
@@ -609,7 +481,7 @@ gdk_text_extents_wc (GdkFont        *font,
                     gint           *ascent,
                     gint           *descent)
 {
-  GdkFontPrivate *private;
+  GdkFontPrivateX *private;
   XCharStruct overall;
   XFontStruct *xfont;
   XFontSet    fontset;
@@ -621,7 +493,7 @@ gdk_text_extents_wc (GdkFont        *font,
   g_return_if_fail (font != NULL);
   g_return_if_fail (text != NULL);
 
-  private = (GdkFontPrivate*) font;
+  private = (GdkFontPrivateX*) font;
 
   switch (font->type)
     {
@@ -684,146 +556,3 @@ gdk_text_extents_wc (GdkFont        *font,
     }
 
 }
-
-void
-gdk_string_extents (GdkFont     *font,
-                   const gchar *string,
-                   gint        *lbearing,
-                   gint        *rbearing,
-                   gint        *width,
-                   gint        *ascent,
-                   gint        *descent)
-{
-  g_return_if_fail (font != NULL);
-  g_return_if_fail (string != NULL);
-
-  gdk_text_extents (font, string, strlen (string),
-                   lbearing, rbearing, width, ascent, descent);
-}
-
-
-gint
-gdk_text_measure (GdkFont     *font,
-                  const gchar *text,
-                  gint         text_length)
-{
-  GdkFontPrivate *private;
-  XCharStruct overall;
-  XFontStruct *xfont;
-  XFontSet    fontset;
-  XRectangle  ink, log;
-  int direction;
-  int font_ascent;
-  int font_descent;
-  gint width;
-
-  g_return_val_if_fail (font != NULL, -1);
-  g_return_val_if_fail (text != NULL, -1);
-
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         XTextExtents (xfont, text, text_length,
-                       &direction, &font_ascent, &font_descent,
-                       &overall);
-       }
-      else
-       {
-         XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
-                         &direction, &font_ascent, &font_descent,
-                         &overall);
-       }
-      width = overall.rbearing;
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      XmbTextExtents (fontset, text, text_length, &ink, &log);
-      width = ink.x + ink.width;
-      break;
-    default:
-      width = 0;
-    }
-  return width;
-}
-
-gint
-gdk_char_measure (GdkFont *font,
-                  gchar    character)
-{
-  g_return_val_if_fail (font != NULL, -1);
-
-  return gdk_text_measure (font, &character, 1);
-}
-
-gint
-gdk_string_height (GdkFont     *font,
-                  const gchar *string)
-{
-  g_return_val_if_fail (font != NULL, -1);
-  g_return_val_if_fail (string != NULL, -1);
-
-  return gdk_text_height (font, string, strlen (string));
-}
-
-gint
-gdk_text_height (GdkFont     *font,
-                const gchar *text,
-                gint         text_length)
-{
-  GdkFontPrivate *private;
-  XCharStruct overall;
-  XFontStruct *xfont;
-  XFontSet    fontset;
-  XRectangle  ink, log;
-  int direction;
-  int font_ascent;
-  int font_descent;
-  gint height;
-
-  g_return_val_if_fail (font != NULL, -1);
-  g_return_val_if_fail (text != NULL, -1);
-
-  private = (GdkFontPrivate*) font;
-
-  switch (font->type)
-    {
-    case GDK_FONT_FONT:
-      xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-       {
-         XTextExtents (xfont, text, text_length,
-                       &direction, &font_ascent, &font_descent,
-                       &overall);
-       }
-      else
-       {
-         XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
-                         &direction, &font_ascent, &font_descent,
-                         &overall);
-       }
-      height = overall.ascent + overall.descent;
-      break;
-    case GDK_FONT_FONTSET:
-      fontset = (XFontSet) private->xfont;
-      XmbTextExtents (fontset, text, text_length, &ink, &log);
-      height = log.height;
-      break;
-    default:
-      height = 0;
-    }
-  return height;
-}
-
-gint
-gdk_char_height (GdkFont *font,
-                gchar    character)
-{
-  g_return_val_if_fail (font != NULL, -1);
-
-  return gdk_text_height (font, &character, 1);
-}
diff --git a/gdk/x11/gdkgc-x11.c b/gdk/x11/gdkgc-x11.c
new file mode 100644 (file)
index 0000000..bf3ff66
--- /dev/null
@@ -0,0 +1,505 @@
+#include "gdkgc.h"
+#include "gdkx.h"
+
+static void gdk_x11_gc_values_to_xvalues (GdkGCValues    *values,
+                                         GdkGCValuesMask mask,
+                                         XGCValues      *xvalues,
+                                         unsigned long  *xvalues_mask);
+     
+static void gdk_x11_gc_destroy    (GdkGC           *gc);
+static void gdk_x11_gc_get_values (GdkGC           *gc,
+                                  GdkGCValues     *values);
+static void gdk_x11_gc_set_values (GdkGC           *gc,
+                                  GdkGCValues     *values,
+                                  GdkGCValuesMask  values_mask);
+static void gdk_x11_gc_set_dashes (GdkGC           *gc,
+                                  gint             dash_offset,
+                                  gchar            dash_list[],
+                                  gint             n);
+
+static GdkGCClass gdk_x11_gc_class = {
+  gdk_x11_gc_destroy,
+  gdk_x11_gc_get_values,
+  gdk_x11_gc_set_values,
+  gdk_x11_gc_set_dashes
+};
+
+GdkGC *
+_gdk_x11_gc_new (GdkDrawable      *drawable,
+                GdkGCValues      *values,
+                GdkGCValuesMask   values_mask)
+{
+  GdkGC *gc;
+  GdkGCPrivate *private;
+  
+  XGCValues xvalues;
+  unsigned long xvalues_mask;
+
+  gc = gdk_gc_alloc ();
+  private = (GdkGCPrivate *)gc;
+
+  private->klass = &gdk_x11_gc_class;
+  private->klass_data = g_new (GdkGCXData, 1);
+    
+  GDK_GC_XDATA (gc)->xdisplay = GDK_DRAWABLE_XDISPLAY (drawable);
+
+  xvalues.function = GXcopy;
+  xvalues.fill_style = FillSolid;
+  xvalues.arc_mode = ArcPieSlice;
+  xvalues.subwindow_mode = ClipByChildren;
+  xvalues.graphics_exposures = True;
+  xvalues_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures;
+
+  gdk_x11_gc_values_to_xvalues (values, values_mask, &xvalues, &xvalues_mask);
+  
+  GDK_GC_XDATA (gc)->xgc = XCreateGC (GDK_GC_XDISPLAY (gc),
+                                     GDK_DRAWABLE_XID (drawable),
+                                     xvalues_mask, &xvalues);
+
+  return gc;
+}
+
+static void
+gdk_x11_gc_destroy (GdkGC *gc)
+{
+  XFreeGC (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc));
+  g_free (GDK_GC_XDATA (gc));
+}
+
+static void
+gdk_x11_gc_get_values (GdkGC       *gc,
+                      GdkGCValues *values)
+{
+  XGCValues xvalues;
+  
+  if (XGetGCValues (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc),
+                   GCForeground | GCBackground | GCFont |
+                   GCFunction | GCTile | GCStipple | /* GCClipMask | */
+                   GCSubwindowMode | GCGraphicsExposures |
+                   GCTileStipXOrigin | GCTileStipYOrigin |
+                   GCClipXOrigin | GCClipYOrigin |
+                   GCLineWidth | GCLineStyle | GCCapStyle |
+                   GCFillStyle | GCJoinStyle, &xvalues))
+    {
+      values->foreground.pixel = xvalues.foreground;
+      values->background.pixel = xvalues.background;
+      values->font = gdk_font_lookup (xvalues.font);
+
+      switch (xvalues.function)
+       {
+       case GXcopy:
+         values->function = GDK_COPY;
+         break;
+       case GXinvert:
+         values->function = GDK_INVERT;
+         break;
+       case GXxor:
+         values->function = GDK_XOR;
+         break;
+       case GXclear:
+         values->function = GDK_CLEAR;
+         break;
+       case GXand:
+         values->function = GDK_AND;
+         break;
+       case GXandReverse:
+         values->function = GDK_AND_REVERSE;
+         break;
+       case GXandInverted:
+         values->function = GDK_AND_INVERT;
+         break;
+       case GXnoop:
+         values->function = GDK_NOOP;
+         break;
+       case GXor:
+         values->function = GDK_OR;
+         break;
+       case GXequiv:
+         values->function = GDK_EQUIV;
+         break;
+       case GXorReverse:
+         values->function = GDK_OR_REVERSE;
+         break;
+       case GXcopyInverted:
+         values->function =GDK_COPY_INVERT;
+         break;
+       case GXorInverted:
+         values->function = GDK_OR_INVERT;
+         break;
+       case GXnand:
+         values->function = GDK_NAND;
+         break;
+       case GXset:
+         values->function = GDK_SET;
+         break;
+       }
+
+      switch (xvalues.fill_style)
+       {
+       case FillSolid:
+         values->fill = GDK_SOLID;
+         break;
+       case FillTiled:
+         values->fill = GDK_TILED;
+         break;
+       case FillStippled:
+         values->fill = GDK_STIPPLED;
+         break;
+       case FillOpaqueStippled:
+         values->fill = GDK_OPAQUE_STIPPLED;
+         break;
+       }
+
+      values->tile = gdk_pixmap_lookup (xvalues.tile);
+      values->stipple = gdk_pixmap_lookup (xvalues.stipple);
+      values->clip_mask = NULL;
+      values->subwindow_mode = xvalues.subwindow_mode;
+      values->ts_x_origin = xvalues.ts_x_origin;
+      values->ts_y_origin = xvalues.ts_y_origin;
+      values->clip_x_origin = xvalues.clip_x_origin;
+      values->clip_y_origin = xvalues.clip_y_origin;
+      values->graphics_exposures = xvalues.graphics_exposures;
+      values->line_width = xvalues.line_width;
+
+      switch (xvalues.line_style)
+       {
+       case LineSolid:
+         values->line_style = GDK_LINE_SOLID;
+         break;
+       case LineOnOffDash:
+         values->line_style = GDK_LINE_ON_OFF_DASH;
+         break;
+       case LineDoubleDash:
+         values->line_style = GDK_LINE_DOUBLE_DASH;
+         break;
+       }
+
+      switch (xvalues.cap_style)
+       {
+       case CapNotLast:
+         values->cap_style = GDK_CAP_NOT_LAST;
+         break;
+       case CapButt:
+         values->cap_style = GDK_CAP_BUTT;
+         break;
+       case CapRound:
+         values->cap_style = GDK_CAP_ROUND;
+         break;
+       case CapProjecting:
+         values->cap_style = GDK_CAP_PROJECTING;
+         break;
+       }
+
+      switch (xvalues.join_style)
+       {
+       case JoinMiter:
+         values->join_style = GDK_JOIN_MITER;
+         break;
+       case JoinRound:
+         values->join_style = GDK_JOIN_ROUND;
+         break;
+       case JoinBevel:
+         values->join_style = GDK_JOIN_BEVEL;
+         break;
+       }
+    }
+  else
+    {
+      memset (values, 0, sizeof (GdkGCValues));
+    }
+}
+
+
+static void
+gdk_x11_gc_set_values (GdkGC           *gc,
+                      GdkGCValues     *values,
+                      GdkGCValuesMask  values_mask)
+{
+  XGCValues xvalues;
+  unsigned long xvalues_mask = 0;
+
+  gdk_x11_gc_values_to_xvalues (values, values_mask, &xvalues, &xvalues_mask);
+
+  XChangeGC (GDK_GC_XDISPLAY (gc),
+            GDK_GC_XGC (gc),
+            xvalues_mask,
+            &xvalues);
+}
+
+static void
+gdk_x11_gc_set_dashes (GdkGC *gc,
+                      gint   dash_offset,
+                      gchar  dash_list[],
+                      gint   n)
+{
+  g_return_if_fail (gc != NULL);
+  g_return_if_fail (dash_list != NULL);
+
+  XSetDashes (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc),
+             dash_offset, dash_list, n);
+}
+
+static void
+gdk_x11_gc_values_to_xvalues (GdkGCValues    *values,
+                             GdkGCValuesMask mask,
+                             XGCValues      *xvalues,
+                             unsigned long  *xvalues_mask)
+{
+  if (mask & GDK_GC_FOREGROUND)
+    {
+      xvalues->foreground = values->foreground.pixel;
+      *xvalues_mask |= GCForeground;
+    }
+  if (mask & GDK_GC_BACKGROUND)
+    {
+      xvalues->background = values->background.pixel;
+      *xvalues_mask |= GCBackground;
+    }
+  if ((mask & GDK_GC_FONT) && (values->font->type == GDK_FONT_FONT))
+    {
+      xvalues->font = ((XFontStruct *) (GDK_FONT_XFONT (values->font)))->fid;
+      *xvalues_mask |= GCFont;
+    }
+  if (mask & GDK_GC_FUNCTION)
+    {
+      switch (values->function)
+       {
+       case GDK_COPY:
+         xvalues->function = GXcopy;
+         break;
+       case GDK_INVERT:
+         xvalues->function = GXinvert;
+         break;
+       case GDK_XOR:
+         xvalues->function = GXxor;
+         break;
+       case GDK_CLEAR:
+         xvalues->function = GXclear;
+         break;
+       case GDK_AND:
+         xvalues->function = GXand;
+         break;
+       case GDK_AND_REVERSE:
+         xvalues->function = GXandReverse;
+         break;
+       case GDK_AND_INVERT:
+         xvalues->function = GXandInverted;
+         break;
+       case GDK_NOOP:
+         xvalues->function = GXnoop;
+         break;
+       case GDK_OR:
+         xvalues->function = GXor;
+         break;
+       case GDK_EQUIV:
+         xvalues->function = GXequiv;
+         break;
+       case GDK_OR_REVERSE:
+         xvalues->function = GXorReverse;
+         break;
+       case GDK_COPY_INVERT:
+         xvalues->function = GXcopyInverted;
+         break;
+       case GDK_OR_INVERT:
+         xvalues->function = GXorInverted;
+         break;
+       case GDK_NAND:
+         xvalues->function = GXnand;
+         break;
+       case GDK_SET:
+         xvalues->function = GXset;
+         break;
+       }
+      *xvalues_mask |= GCFunction;
+    }
+  if (mask & GDK_GC_FILL)
+    {
+      switch (values->fill)
+       {
+       case GDK_SOLID:
+         xvalues->fill_style = FillSolid;
+         break;
+       case GDK_TILED:
+         xvalues->fill_style = FillTiled;
+         break;
+       case GDK_STIPPLED:
+         xvalues->fill_style = FillStippled;
+         break;
+       case GDK_OPAQUE_STIPPLED:
+         xvalues->fill_style = FillOpaqueStippled;
+         break;
+       }
+      *xvalues_mask |= GCFillStyle;
+    }
+  if (mask & GDK_GC_TILE)
+    {
+      if (values->tile)
+       xvalues->tile = GDK_DRAWABLE_XID (values->tile);
+      else
+       xvalues->tile = None;
+      
+      *xvalues_mask |= GCTile;
+    }
+  if (mask & GDK_GC_STIPPLE)
+    {
+      if (values->stipple)
+       xvalues->stipple = GDK_DRAWABLE_XID (values->stipple);
+      else
+       xvalues->stipple = None;
+      
+      *xvalues_mask |= GCStipple;
+    }
+  if (mask & GDK_GC_CLIP_MASK)
+    {
+      if (values->clip_mask)
+       xvalues->clip_mask = GDK_DRAWABLE_XID (values->clip_mask);
+      else
+       xvalues->clip_mask = None;
+
+      *xvalues_mask |= GCClipMask;
+      
+    }
+  if (mask & GDK_GC_SUBWINDOW)
+    {
+      xvalues->subwindow_mode = values->subwindow_mode;
+      *xvalues_mask |= GCSubwindowMode;
+    }
+  if (mask & GDK_GC_TS_X_ORIGIN)
+    {
+      xvalues->ts_x_origin = values->ts_x_origin;
+      *xvalues_mask |= GCTileStipXOrigin;
+    }
+  if (mask & GDK_GC_TS_Y_ORIGIN)
+    {
+      xvalues->ts_y_origin = values->ts_y_origin;
+      *xvalues_mask |= GCTileStipYOrigin;
+    }
+  if (mask & GDK_GC_CLIP_X_ORIGIN)
+    {
+      xvalues->clip_x_origin = values->clip_x_origin;
+      *xvalues_mask |= GCClipXOrigin;
+    }
+  if (mask & GDK_GC_CLIP_Y_ORIGIN)
+    {
+      xvalues->clip_y_origin = values->clip_y_origin;
+      *xvalues_mask |= GCClipYOrigin;
+    }
+
+  if (mask & GDK_GC_EXPOSURES)
+    xvalues->graphics_exposures = values->graphics_exposures;
+  else
+    xvalues->graphics_exposures = False;
+  *xvalues_mask |= GCGraphicsExposures;
+
+  if (mask & GDK_GC_LINE_WIDTH)
+    {
+      xvalues->line_width = values->line_width;
+      *xvalues_mask |= GCLineWidth;
+    }
+  if (mask & GDK_GC_LINE_STYLE)
+    {
+      switch (values->line_style)
+       {
+       case GDK_LINE_SOLID:
+         xvalues->line_style = LineSolid;
+         break;
+       case GDK_LINE_ON_OFF_DASH:
+         xvalues->line_style = LineOnOffDash;
+         break;
+       case GDK_LINE_DOUBLE_DASH:
+         xvalues->line_style = LineDoubleDash;
+         break;
+       }
+      *xvalues_mask |= GCLineStyle;
+    }
+  if (mask & GDK_GC_CAP_STYLE)
+    {
+      switch (values->cap_style)
+       {
+       case GDK_CAP_NOT_LAST:
+         xvalues->cap_style = CapNotLast;
+         break;
+       case GDK_CAP_BUTT:
+         xvalues->cap_style = CapButt;
+         break;
+       case GDK_CAP_ROUND:
+         xvalues->cap_style = CapRound;
+         break;
+       case GDK_CAP_PROJECTING:
+         xvalues->cap_style = CapProjecting;
+         break;
+       }
+      *xvalues_mask |= GCCapStyle;
+    }
+  if (mask & GDK_GC_JOIN_STYLE)
+    {
+      switch (values->join_style)
+       {
+       case GDK_JOIN_MITER:
+         xvalues->join_style = JoinMiter;
+         break;
+       case GDK_JOIN_ROUND:
+         xvalues->join_style = JoinRound;
+         break;
+       case GDK_JOIN_BEVEL:
+         xvalues->join_style = JoinBevel;
+         break;
+       }
+      *xvalues_mask |= GCJoinStyle;
+    }
+
+}
+
+void
+gdk_gc_set_clip_rectangle (GdkGC       *gc,
+                          GdkRectangle *rectangle)
+{
+  XRectangle xrectangle;
+   
+  g_return_if_fail (gc != NULL);
+
+  if (rectangle)
+    {
+      xrectangle.x = rectangle->x; 
+      xrectangle.y = rectangle->y;
+      xrectangle.width = rectangle->width;
+      xrectangle.height = rectangle->height;
+      
+      XSetClipRectangles (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), 0, 0,
+                         &xrectangle, 1, Unsorted);
+    }
+  else
+    XSetClipMask (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), None);
+} 
+
+void
+gdk_gc_set_clip_region (GdkGC           *gc,
+                       GdkRegion        *region)
+{
+  GdkGCPrivate *private;
+
+  g_return_if_fail (gc != NULL);
+
+  private = (GdkGCPrivate*) gc;
+
+  if (region)
+    {
+      GdkRegionPrivate *region_private;
+
+      region_private = (GdkRegionPrivate*) region;
+      XSetRegion (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), region_private->xregion);
+    }
+  else
+    XSetClipMask (GDK_GC_XDISPLAY (gc), GDK_GC_XGC (gc), None);
+}
+
+
+void
+gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
+{
+  g_return_if_fail (dst_gc != NULL);
+  g_return_if_fail (src_gc != NULL);
+  
+  XCopyGC (GDK_GC_XDISPLAY (src_gc), GDK_GC_XGC (src_gc), ~((~1) << GCLastBit),
+          GDK_GC_XGC (dst_gc));
+}
index ae6c066f963119e4845af9030d6d7d21dfbcda09..9a3d6c5f9519b392f0e13f31f50a5edd3a3607fa 100644 (file)
  */
 
 #include <stdio.h>
-#include <X11/Xlib.h>
+
 #include "gdktypes.h"
-#include "gdkprivate.h"
+#include "gdkprivate-x11.h"
 #include "config.h"
 
-guint             gdk_debug_flags = 0;
-gint              gdk_use_xshm = TRUE;
+gboolean          gdk_use_xshm = TRUE;
 gchar            *gdk_display_name = NULL;
 Display          *gdk_display = NULL;
 gint              gdk_screen;
 Window            gdk_root_window;
 Window            gdk_leader_window;
-GdkWindowPrivate  gdk_root_parent = { { NULL, }, NULL, };
 Atom              gdk_wm_delete_window;
 Atom              gdk_wm_take_focus;
 Atom              gdk_wm_protocols;
 Atom              gdk_wm_window_protocols[2];
 Atom              gdk_selection_property;
-GdkDndCursorInfo  gdk_dnd_cursorinfo = {None, None, NULL, NULL,
-                                       {0,0}, {0,0}, NULL};
-GdkDndGlobals     gdk_dnd = {None,None,None,
-                            None,None,None,
-                            None,
-                            &gdk_dnd_cursorinfo,
-                            NULL,
-                            0,
-                            FALSE, FALSE, FALSE,
-                            None,
-                            {0,0},
-                            {0,0}, {0,0},
-                            {0,0,0,0}, NULL, None, 0};
 gchar            *gdk_progclass = NULL;
-gint              gdk_error_code = 0;
-gint              gdk_error_warnings = TRUE;
-gint              gdk_null_window_warnings = TRUE;
-GList            *gdk_default_filters = NULL;
+gboolean          gdk_null_window_warnings = TRUE;
 
-gboolean      gdk_xim_using;           /* using XIM Protocol if TRUE */
+gboolean          gdk_xim_using;               /* using XIM Protocol if TRUE */
 #ifdef USE_XIM
-GdkICPrivate *gdk_xim_ic;              /* currently using IC */
+GdkICPrivate     *gdk_xim_ic;          /* currently using IC */
 #endif /* USE_XIM */
-GdkWindow    *gdk_xim_window;          /* currently using Widow */
+GdkWindow        *gdk_xim_window;              /* currently using Widow */
 
 GdkWindowPrivate *gdk_xgrab_window = NULL;  /* Window that currently holds the
                                             *  x pointer grab
                                             */
-
-GMutex *gdk_threads_mutex = NULL;          /* Global GDK lock */
-
-#ifdef USE_XIM
-GdkICPrivate *gdk_xim_ic;              /* currently using IC */
-GdkWindow *gdk_xim_window;             /* currently using Window */
-#endif
-
index 4facec7e75042273946b37f41bfb9fe97a5fd895..cee55c711524dbee3db13675258b9dffa0d808f1 100644 (file)
 #include "gdkprivate.h"
 #include "gdkx.h"
 
-
-static void gdk_image_put_normal (GdkDrawable *drawable,
-                                 GdkGC       *gc,
-                                 GdkImage    *image,
-                                 gint         xsrc,
-                                 gint         ysrc,
-                                 gint         xdest,
-                                 gint         ydest,
-                                 gint         width,
-                                 gint         height);
-static void gdk_image_put_shared (GdkDrawable *drawable,
-                                 GdkGC       *gc,
-                                 GdkImage    *image,
-                                 gint         xsrc,
-                                 gint         ysrc,
-                                 gint         xdest,
-                                 gint         ydest,
-                                 gint         width,
-                                 gint         height);
-
+static void gdk_x11_image_destroy (GdkImage    *image);
+static void gdk_image_put_normal  (GdkImage    *image,
+                                  GdkDrawable *drawable,
+                                  GdkGC       *gc,
+                                  gint         xsrc,
+                                  gint         ysrc,
+                                  gint         xdest,
+                                  gint         ydest,
+                                  gint         width,
+                                  gint         height);
+static void gdk_image_put_shared  (GdkImage    *image,
+                                  GdkDrawable *drawable,
+                                  GdkGC       *gc,
+                                  gint         xsrc,
+                                  gint         ysrc,
+                                  gint         xdest,
+                                  gint         ydest,
+                                  gint         width,
+                                  gint         height);
+
+static GdkImageClass image_class_normal = {
+  gdk_x11_image_destroy,
+  gdk_image_put_normal
+};
+
+static GdkImageClass image_class_shared = {
+  gdk_x11_image_destroy,
+  gdk_image_put_shared
+};
 
 static GList *image_list = NULL;
 
@@ -90,7 +99,7 @@ gdk_image_exit (void)
   while (image_list)
     {
       image = image_list->data;
-      gdk_image_destroy (image);
+      gdk_x11_image_destroy (image);
     }
 }
 
@@ -102,11 +111,12 @@ gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
 {
         Visual *xvisual;
         GdkImage *image;
-        GdkImagePrivate *private;
-        private = g_new(GdkImagePrivate, 1);
+        GdkImagePrivateX *private;
+        private = g_new(GdkImagePrivateX, 1);
         image = (GdkImage *) private;
         private->xdisplay = gdk_display;
-        private->image_put = gdk_image_put_normal;
+        private->base.ref_count = 1;
+        private->base.klass = &image_class_normal;
         image->type = GDK_IMAGE_NORMAL;
         image->visual = visual;
         image->width = w;
@@ -168,7 +178,7 @@ gdk_image_new (GdkImageType  type,
               gint          height)
 {
   GdkImage *image;
-  GdkImagePrivate *private;
+  GdkImagePrivateX *private;
 #ifdef USE_SHM
   XShmSegmentInfo *x_shm_info;
 #endif /* USE_SHM */
@@ -184,11 +194,11 @@ gdk_image_new (GdkImageType  type,
       break;
 
     default:
-      private = g_new (GdkImagePrivate, 1);
+      private = g_new (GdkImagePrivateX, 1);
       image = (GdkImage*) private;
 
+      private->base.ref_count = 1;
       private->xdisplay = gdk_display;
-      private->image_put = NULL;
 
       image->type = type;
       image->visual = visual;
@@ -204,7 +214,7 @@ gdk_image_new (GdkImageType  type,
 #ifdef USE_SHM
          if (gdk_use_xshm)
            {
-             private->image_put = gdk_image_put_shared;
+             private->base.klass = &image_class_shared;
 
              private->x_shm_info = g_new (XShmSegmentInfo, 1);
              x_shm_info = private->x_shm_info;
@@ -295,7 +305,7 @@ gdk_image_new (GdkImageType  type,
          return NULL;
 #endif /* USE_SHM */
        case GDK_IMAGE_NORMAL:
-         private->image_put = gdk_image_put_normal;
+         private->base.klass = &image_class_normal;
 
          private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth,
                                          ZPixmap, 0, 0, width, height, 32, 0);
@@ -308,6 +318,7 @@ gdk_image_new (GdkImageType  type,
          break;
 
        case GDK_IMAGE_FASTEST:
+       case GDK_IMAGE_SHARED_PIXMAP:
          g_assert_not_reached ();
        }
 
@@ -331,18 +342,19 @@ gdk_image_get (GdkWindow *window,
               gint       height)
 {
   GdkImage *image;
-  GdkImagePrivate *private;
+  GdkImagePrivateX *private;
 
   g_return_val_if_fail (window != NULL, NULL);
 
   if (GDK_DRAWABLE_DESTROYED (window))
     return NULL;
 
-  private = g_new (GdkImagePrivate, 1);
+  private = g_new (GdkImagePrivateX, 1);
   image = (GdkImage*) private;
 
+  private->base.ref_count = 1;
+  private->base.klass = &image_class_normal;
   private->xdisplay = gdk_display;
-  private->image_put = gdk_image_put_normal;
   private->ximage = XGetImage (private->xdisplay,
                               GDK_DRAWABLE_XID (window),
                               x, y, width, height,
@@ -375,11 +387,11 @@ gdk_image_get_pixel (GdkImage *image,
                     gint y)
 {
   guint32 pixel;
-  GdkImagePrivate *private;
+  GdkImagePrivateX *private;
 
   g_return_val_if_fail (image != NULL, 0);
 
-  private = (GdkImagePrivate *) image;
+  private = (GdkImagePrivateX *) image;
 
   pixel = XGetPixel (private->ximage, x, y);
 
@@ -392,26 +404,26 @@ gdk_image_put_pixel (GdkImage *image,
                     gint y,
                     guint32 pixel)
 {
-  GdkImagePrivate *private;
+  GdkImagePrivateX *private;
 
   g_return_if_fail (image != NULL);
 
-  private = (GdkImagePrivate *) image;
+  private = (GdkImagePrivateX *) image;
 
   pixel = XPutPixel (private->ximage, x, y, pixel);
 }
 
-void
-gdk_image_destroy (GdkImage *image)
+static void
+gdk_x11_image_destroy (GdkImage *image)
 {
-  GdkImagePrivate *private;
+  GdkImagePrivateX *private;
 #ifdef USE_SHM
   XShmSegmentInfo *x_shm_info;
 #endif /* USE_SHM */
 
   g_return_if_fail (image != NULL);
 
-  private = (GdkImagePrivate*) image;
+  private = (GdkImagePrivateX*) image;
   switch (image->type)
     {
     case GDK_IMAGE_NORMAL:
@@ -437,6 +449,7 @@ gdk_image_destroy (GdkImage *image)
       break;
 
     case GDK_IMAGE_FASTEST:
+    case GDK_IMAGE_SHARED_PIXMAP:
       g_assert_not_reached ();
     }
 
@@ -444,9 +457,9 @@ gdk_image_destroy (GdkImage *image)
 }
 
 static void
-gdk_image_put_normal (GdkDrawable *drawable,
+gdk_image_put_normal (GdkImage    *image,
+                     GdkDrawable *drawable,
                      GdkGC       *gc,
-                     GdkImage    *image,
                      gint         xsrc,
                      gint         ysrc,
                      gint         xdest,
@@ -454,8 +467,7 @@ gdk_image_put_normal (GdkDrawable *drawable,
                      gint         width,
                      gint         height)
 {
-  GdkImagePrivate *image_private;
-  GdkGCPrivate *gc_private;
+  GdkImagePrivateX *image_private;
 
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (image != NULL);
@@ -463,20 +475,19 @@ gdk_image_put_normal (GdkDrawable *drawable,
 
   if (GDK_DRAWABLE_DESTROYED (drawable))
     return;
-  image_private = (GdkImagePrivate*) image;
-  gc_private = (GdkGCPrivate*) gc;
+  image_private = (GdkImagePrivateX*) image;
 
   g_return_if_fail (image->type == GDK_IMAGE_NORMAL);
 
   XPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), 
-            gc_private->xgc, image_private->ximage,
+            GDK_GC_XGC (gc), image_private->ximage,
             xsrc, ysrc, xdest, ydest, width, height);
 }
 
 static void
-gdk_image_put_shared (GdkDrawable *drawable,
+gdk_image_put_shared (GdkImage    *image,
+                     GdkDrawable *drawable,
                      GdkGC       *gc,
-                     GdkImage    *image,
                      gint         xsrc,
                      gint         ysrc,
                      gint         xdest,
@@ -485,8 +496,7 @@ gdk_image_put_shared (GdkDrawable *drawable,
                      gint         height)
 {
 #ifdef USE_SHM
-  GdkImagePrivate *image_private;
-  GdkGCPrivate *gc_private;
+  GdkImagePrivateX *image_private;
 
   g_return_if_fail (drawable != NULL);
   g_return_if_fail (image != NULL);
@@ -494,13 +504,12 @@ gdk_image_put_shared (GdkDrawable *drawable,
 
   if (GDK_DRAWABLE_DESTROYED (drawable))
     return;
-  image_private = (GdkImagePrivate*) image;
-  gc_private = (GdkGCPrivate*) gc;
+  image_private = (GdkImagePrivateX*) image;
 
   g_return_if_fail (image->type == GDK_IMAGE_SHARED);
 
   XShmPutImage (GDK_DRAWABLE_XDISPLAY (drawable), GDK_DRAWABLE_XID (drawable), 
-               gc_private->xgc, image_private->ximage,
+               GDK_GC_XGC (gc), image_private->ximage,
                xsrc, ysrc, xdest, ydest, width, height, False);
 #else /* USE_SHM */
   g_error ("trying to draw shared memory image when gdk was compiled without shared memory support");
index 773a0436b78b6b679042bc5ee612545063122572..982e85c7c8e3078c9917e80a0445ee56c391012c 100644 (file)
@@ -24,8 +24,6 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#ifdef XINPUT_GXI
-
 /* #define DEBUG_SWITCHING */
 
 #include <gxid_lib.h>
@@ -645,5 +643,3 @@ gdk_input_gxi_ungrab_pointer (guint32 time)
       tmp_list = tmp_list->next;
     }
 }
-
-#endif /* XINPUT_GXI */
index 7695726bf7f582671f6edf64b9e0757962437345..f04ef190ea184a09b0cac424383a4474cc1fe756 100644 (file)
@@ -24,8 +24,6 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#ifdef XINPUT_NONE
-
 static void gdk_input_none_get_pointer (GdkWindow       *window,
                                        guint32   deviceid,
                                        gdouble         *x,
@@ -77,5 +75,3 @@ gdk_input_none_get_pointer (GdkWindow       *window,
   if (xtilt) *xtilt = 0;
   if (ytilt) *ytilt = 0;
 }
-
-#endif /* XINPUT_NONE */
index d9bb835b8919c0db66ce7f92eb73d96f80348cc8..4e395ef0abae2a604460e66db5dc99cb2ae61503 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
+#include "gdkinputprivate.h"
+#include "gdkx.h"
 
 /* Forward declarations */
-static void gdk_input_get_root_relative_geometry (Display *dpy, Window w, 
-                                                 int *x_ret, int *y_ret,
-                                                 int *width_ret, 
-                                                 int *height_ret);
 static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device, 
                                              gint include_core);
-static void gdk_input_common_find_events(GdkWindow *window,
-                                        GdkDevicePrivate *gdkdev,
-                                        gint mask,
-                                        XEventClass *classes,
-                                        int *num_classes);
-static void gdk_input_common_select_events(GdkWindow *window,
-                                          GdkDevicePrivate *gdkdev);
 static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
                                            GdkInputWindow *input_window,
                                            gint *axis_data,
@@ -47,34 +37,21 @@ static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
                                            gdouble *pressure,
                                            gdouble *xtilt, gdouble *ytilt);
 static guint gdk_input_translate_state(guint state, guint device_state);
-static gint gdk_input_common_init(gint include_core);
-static gint  gdk_input_common_other_event (GdkEvent *event, 
-                                          XEvent *xevent, 
-                                          GdkInputWindow *input_window,
-                                          GdkDevicePrivate *gdkdev);
-static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
-static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
-                                                     guint32 deviceid,
-                                                     guint32 start,
-                                                     guint32 stop,
-                                                     gint *nevents_return);
-static void  gdk_input_common_get_pointer     (GdkWindow       *window,
-                                              guint32     deviceid,
-                                              gdouble         *x,
-                                              gdouble         *y,
-                                              gdouble         *pressure,
-                                              gdouble         *xtilt,
-                                              gdouble         *ytilt,
-                                              GdkModifierType *mask);
-
-#define GDK_MAX_DEVICE_CLASSES 13
+void  gdk_input_common_get_pointer     (GdkWindow       *window,
+                                       guint32    deviceid,
+                                       gdouble         *x,
+                                       gdouble         *y,
+                                       gdouble         *pressure,
+                                       gdouble         *xtilt,
+                                       gdouble         *ytilt,
+                                       GdkModifierType *mask);
 
 /* Global variables */
 
 static gint gdk_input_root_width;
 static gint gdk_input_root_height;
 
-static void
+void
 gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
                               int *width_ret, int *height_ret)
 {
@@ -301,7 +278,7 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
   return gdkdev;
 }
 
-static void
+void
 gdk_input_common_find_events(GdkWindow *window,
                             GdkDevicePrivate *gdkdev,
                             gint mask,
@@ -403,7 +380,7 @@ gdk_input_common_find_events(GdkWindow *window,
   *num_classes = i;
 }
 
-static void
+void
 gdk_input_common_select_events(GdkWindow *window,
                               GdkDevicePrivate *gdkdev)
 {
@@ -460,7 +437,7 @@ gdk_input_common_init(gint include_core)
       XFreeDeviceList(devices);
     }
 
-  gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
+  gdk_input_devices = g_list_append (gdk_input_devices, (gpointer)&gdk_input_core_info);
 
   return TRUE;
 }
@@ -581,10 +558,11 @@ gdk_input_translate_state(guint state, guint device_state)
   return device_state | (state & 0xFF);
 }
 
-static gint 
-gdk_input_common_other_event (GdkEvent *event, 
-                             XEvent *xevent, 
-                             GdkInputWindow *input_window,
+
+gint 
+gdk_input_common_other_event (GdkEvent         *event,
+                             XEvent           *xevent,
+                             GdkInputWindow   *input_window,
                              GdkDevicePrivate *gdkdev)
 {
   if ((xevent->type == gdkdev->buttonpress_type) ||
@@ -736,7 +714,7 @@ gdk_input_common_other_event (GdkEvent *event,
   return -1;                   /* wasn't one of our event types */
 }
 
-static void
+void
 gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
 {
   int i;
@@ -755,10 +733,11 @@ gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
     }
 }
 
-void gdk_input_common_set_key (guint32 deviceid,
-                              guint   index,
-                              guint   keyval,
-                              GdkModifierType modifiers)
+void 
+gdk_input_common_set_key (guint32 deviceid,
+                         guint   index,
+                         guint   keyval,
+                         GdkModifierType modifiers)
 {
   GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
   
@@ -770,7 +749,7 @@ void gdk_input_common_set_key (guint32 deviceid,
   gdkdev->info.keys[index].modifiers = modifiers;
 }
 
-static GdkTimeCoord *
+GdkTimeCoord *
 gdk_input_common_motion_events (GdkWindow *window,
                                guint32 deviceid,
                                guint32 start,
@@ -819,7 +798,7 @@ gdk_input_common_motion_events (GdkWindow *window,
     return NULL;
 }
 
-static void 
+void 
 gdk_input_common_get_pointer     (GdkWindow       *window,
                                  guint32          deviceid,
                                  gdouble         *x,
@@ -888,5 +867,3 @@ gdk_input_common_get_pointer     (GdkWindow       *window,
        }
     }
 }
-
-#endif
index d4020ae1638b7a7c2cbad55b0a4d304bb17f7994..6cb6d87b6dcd8dc28155f7f2eeebbb5d909208dd 100644 (file)
@@ -17,6 +17,9 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include "gdkinputprivate.h"
+#include "gdkx.h"
+
 /*
  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
@@ -24,8 +27,6 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#ifdef XINPUT_XFREE
-
 /* forward declarations */
 
 static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
@@ -42,10 +43,10 @@ static gint gdk_input_xfree_enable_window(GdkWindow *window,
 static gint gdk_input_xfree_disable_window(GdkWindow *window,
                                           GdkDevicePrivate *gdkdev);
 static gint gdk_input_xfree_grab_pointer (GdkWindow *     window,
-                                       gint            owner_events,
-                                       GdkEventMask    event_mask,
-                                       GdkWindow *     confine_to,
-                                       guint32         time);
+                                         gint            owner_events,
+                                         GdkEventMask    event_mask,
+                                         GdkWindow *     confine_to,
+                                         guint32         time);
 static void gdk_input_xfree_ungrab_pointer (guint32 time);
 
 void 
@@ -370,5 +371,3 @@ gdk_input_xfree_ungrab_pointer (guint32 time)
        }
     }
 }
-
-#endif /* XINPUT_XFREE */
index 334c3d46d82930d2d7bac7ad3d0cf5cc446458da..348251458dfa6d6243b0ccce57815242c1bdf170 100644 (file)
 #include "gdkprivate.h"
 #include "gdkinputprivate.h"
 
-/* Forward declarations */
-
-static gint gdk_input_enable_window (GdkWindow *window,
-                                    GdkDevicePrivate *gdkdev);
-static gint gdk_input_disable_window (GdkWindow *window,
-                                     GdkDevicePrivate *gdkdev);
-static GdkInputWindow *gdk_input_window_find (GdkWindow *window);
-static GdkDevicePrivate *gdk_input_find_device (guint32 id);
-
-
-/* Incorporate the specific routines depending on compilation options */
-
 static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
 
-static const GdkDeviceInfo gdk_input_core_info =
+const GdkDeviceInfo gdk_input_core_info =
 {
   GDK_CORE_POINTER,
   "Core Pointer",
@@ -67,15 +55,8 @@ gchar            *gdk_input_gxid_host;
 gint              gdk_input_gxid_port;
 gint              gdk_input_ignore_core;
 
-/* Local variables */
-
-static GList            *gdk_input_devices;
-static GList            *gdk_input_windows;
-
-#include "gdkinputnone.h"
-#include "gdkinputcommon.h"
-#include "gdkinputxfree.h"
-#include "gdkinputgxi.h"
+GList            *gdk_input_devices;
+GList            *gdk_input_windows;
 
 GList *
 gdk_input_list_devices (void)
@@ -178,7 +159,7 @@ gdk_input_motion_events (GdkWindow *window,
     }
 }
 
-static gint
+gint
 gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
 {
   if (gdk_input_vtable.enable_window)
@@ -187,7 +168,7 @@ gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
     return TRUE;
 }
 
-static gint
+gint
 gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
 {
   if (gdk_input_vtable.disable_window)
@@ -197,7 +178,7 @@ gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
 }
 
 
-static GdkInputWindow *
+GdkInputWindow *
 gdk_input_window_find(GdkWindow *window)
 {
   GList *tmp_list;
@@ -324,7 +305,7 @@ gdk_input_exit (void)
   g_list_free(gdk_input_windows);
 }
 
-static GdkDevicePrivate *
+GdkDevicePrivate *
 gdk_input_find_device(guint32 id)
 {
   GList *tmp_list = gdk_input_devices;
index 0f41c462b4eb95560c4876ad261808dc60797bae..d1f8a66d140f976d7c9ef814c5333c2067373306 100644 (file)
 #ifndef __GDK_INPUTPRIVATE_H__
 #define __GDK_INPUTPRIVATE_H__
 
+#include "config.h"
+#include "gdkinput.h"
+#include "gdkevents.h"
+
 #ifndef XINPUT_NONE
 #include <X11/extensions/XInput.h>
 #endif
@@ -147,6 +151,10 @@ struct _GdkInputWindow
 
 /* Global data */
 
+extern const GdkDeviceInfo gdk_input_core_info;
+extern GList *gdk_input_devices;
+extern GList *gdk_input_windows;
+
 extern GdkInputVTable gdk_input_vtable;
 /* information about network port and host for gxid daemon */
 extern gchar           *gdk_input_gxid_host;
@@ -155,8 +163,63 @@ extern gint             gdk_input_ignore_core;
 
 /* Function declarations */
 
+GdkDevicePrivate * gdk_input_find_device    (guint32           id);
+GdkInputWindow *   gdk_input_window_find    (GdkWindow        *window);
+void               gdk_input_window_destroy (GdkWindow        *window);
+void               gdk_input_init           (void);
+void               gdk_input_exit           (void);
+gint               gdk_input_enable_window  (GdkWindow        *window,
+                                            GdkDevicePrivate *gdkdev);
+gint               gdk_input_disable_window (GdkWindow        *window,
+                                            GdkDevicePrivate *gdkdev);
+
+#ifndef XINPUT_NONE
+
+#define GDK_MAX_DEVICE_CLASSES 13
+
+gint           gdk_input_common_init                (gint              include_core);
+void           gdk_input_get_root_relative_geometry (Display          *dpy,
+                                                    Window            w,
+                                                    int              *x_ret,
+                                                    int              *y_ret,
+                                                    int              *width_ret,
+                                                    int              *height_ret);
+void           gdk_input_common_find_events         (GdkWindow        *window,
+                                                    GdkDevicePrivate *gdkdev,
+                                                    gint              mask,
+                                                    XEventClass      *classes,
+                                                    int              *num_classes);
+void           gdk_input_common_select_events       (GdkWindow        *window,
+                                                    GdkDevicePrivate *gdkdev);
+gint           gdk_input_common_other_event         (GdkEvent         *event,
+                                                    XEvent           *xevent,
+                                                    GdkInputWindow   *input_window,
+                                                    GdkDevicePrivate *gdkdev);
+void           gdk_input_common_get_pointer         (GdkWindow        *window,
+                                                    guint32           deviceid,
+                                                    gdouble          *x,
+                                                    gdouble          *y,
+                                                    gdouble          *pressure,
+                                                    gdouble          *xtilt,
+                                                    gdouble          *ytilt,
+                                                    GdkModifierType  *mask);
+void           gdk_input_common_set_key             (guint32           deviceid,
+                                                    guint             index,
+                                                    guint             keyval,
+                                                    GdkModifierType   modifiers);
+void           gdk_input_common_set_axes            (guint32           deviceid,
+                                                    GdkAxisUse       *axes);
+GdkTimeCoord * gdk_input_common_motion_events       (GdkWindow        *window,
+                                                    guint32           deviceid,
+                                                    guint32           start,
+                                                    guint32           stop,
+                                                    gint             *nevents_return);
+
+#endif /* !XINPUT_NONE */
+
+GdkDevicePrivate *gdk_input_find_device (guint32 id);
+GdkInputWindow *gdk_input_window_find (GdkWindow *window);
 void gdk_input_window_destroy (GdkWindow *window);
-void gdk_input_init           (void);
 void gdk_input_exit           (void);
 
 #endif /* __GDK_INPUTPRIVATE_H__ */
index 4e8b83f803cd5073a86d68a0b0465aad2ab31bab..de696cca984ddc36a51bcef744b72c869802e3b8 100644 (file)
@@ -77,15 +77,10 @@ static void  gdkx_XConvertCase      (KeySym        symbol,
 #define XConvertCase gdkx_XConvertCase
 #endif
 
-static void        gdk_exit_func                (void);
 static int         gdk_x_error                  (Display     *display, 
                                                  XErrorEvent *error);
 static int         gdk_x_io_error               (Display     *display);
 
-GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
-                                        GdkEvent  *event,
-                                        gpointer   data);
-
 /* Private variable declarations
  */
 static int gdk_initialized = 0;                            /* 1 if the library is initialized,
@@ -93,9 +88,7 @@ static int gdk_initialized = 0;                           /* 1 if the library is initialized,
                                                     */
 
 static gint autorepeat;
-
-static GSList *gdk_error_traps = NULL;               /* List of error traps */
-static GSList *gdk_error_trap_free_list = NULL;      /* Free list */
+static gboolean gdk_synchronize = FALSE;
 
 #ifdef G_ENABLE_DEBUG
 static const GDebugKey gdk_debug_keys[] = {
@@ -110,258 +103,60 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
 
 #endif /* G_ENABLE_DEBUG */
 
-/*
- *--------------------------------------------------------------
- * gdk_init_heck
- *
- *   Initialize the library for use.
- *
- * Arguments:
- *   "argc" is the number of arguments.
- *   "argv" is an array of strings.
- *
- * Results:
- *   "argc" and "argv" are modified to reflect any arguments
- *   which were not handled. (Such arguments should either
- *   be handled by the application or dismissed). If initialization
- *   fails, returns FALSE, otherwise TRUE.
- *
- * Side effects:
- *   The library is initialized.
- *
- *--------------------------------------------------------------
- */
+static void
+gdk_arg_xim_preedit_cb (const gchar *arg, const gchar *value, gpointer cb_data)
+{
+  if (strcmp ("none", value) == 0)
+    gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
+  else if (strcmp ("nothing", value) == 0)
+    gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
+  else if (strcmp ("area", value) == 0)
+    gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
+  else if (strcmp ("position", value) == 0)
+    gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
+  else if (strcmp ("callbacks", value) == 0)
+    gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
+}
+
+static void
+gdk_arg_xim_status_cb (const gchar *arg, const gchar *value, gpointer cb_data)
+{
+  if (strcmp ("none", value) == 0)
+    gdk_im_set_best_style (GDK_IM_STATUS_NONE);
+  else if (strcmp ("nothing", value) == 0)
+    gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
+  else if (strcmp ("area", value) == 0)
+    gdk_im_set_best_style (GDK_IM_STATUS_AREA);
+  else if (strcmp ("callbacks", value) == 0)
+    gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
+}
+
+GdkArgDesc _gdk_windowing_args[] = {
+  { "display",     GDK_ARG_STRING,   &gdk_display_name,    (GdkArgFunc)NULL   },
+  { "sync",        GDK_ARG_BOOL,     &gdk_synchronize,     (GdkArgFunc)NULL   },
+  { "no-xshm",     GDK_ARG_NOBOOL,   &gdk_use_xshm,        (GdkArgFunc)NULL   },
+  { "class",       GDK_ARG_STRING,   &gdk_progclass,       (GdkArgFunc)NULL   },
+  { "gxid-host",   GDK_ARG_STRING,   &gdk_input_gxid_host, (GdkArgFunc)NULL   },
+  { "gxid-port",   GDK_ARG_INT,      &gdk_input_gxid_port, (GdkArgFunc)NULL   },
+  { "xim-preedit", GDK_ARG_CALLBACK, NULL,                 gdk_arg_xim_preedit_cb },
+  { "xim-status",  GDK_ARG_CALLBACK, NULL,                 gdk_arg_xim_status_cb  },
+  { NULL }
+};
 
 gboolean
-gdk_init_check (int     *argc,
-               char ***argv)
+_gdk_windowing_init_check (int argc, char **argv)
 {
   XKeyboardState keyboard_state;
-  gint synchronize;
-  gint i, j, k;
   XClassHint *class_hint;
-  gchar **argv_orig = NULL;
-  gint argc_orig = 0;
-  
-  if (gdk_initialized)
-    return TRUE;
-  
-  if (g_thread_supported ())
-    gdk_threads_mutex = g_mutex_new ();
-  
-  if (argc && argv)
-    {
-      argc_orig = *argc;
-      
-      argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
-      for (i = 0; i < argc_orig; i++)
-       argv_orig[i] = g_strdup ((*argv)[i]);
-      argv_orig[argc_orig] = NULL;
-    }
-  
-  gdk_display_name = NULL;
   
   XSetErrorHandler (gdk_x_error);
   XSetIOErrorHandler (gdk_x_io_error);
   
-  synchronize = FALSE;
-  
-#ifdef G_ENABLE_DEBUG
-  {
-    gchar *debug_string = getenv("GDK_DEBUG");
-    if (debug_string != NULL)
-      gdk_debug_flags = g_parse_debug_string (debug_string,
-                                             (GDebugKey *) gdk_debug_keys,
-                                             gdk_ndebug_keys);
-  }
-#endif /* G_ENABLE_DEBUG */
-  
-  if (argc && argv)
-    {
-      if (*argc > 0)
-       {
-         gchar *d;
-         
-         d = strrchr((*argv)[0],'/');
-         if (d != NULL)
-           g_set_prgname (d + 1);
-         else
-           g_set_prgname ((*argv)[0]);
-       }
-      
-      for (i = 1; i < *argc;)
-       {
-#ifdef G_ENABLE_DEBUG    
-         if ((strcmp ("--gdk-debug", (*argv)[i]) == 0) ||
-             (strncmp ("--gdk-debug=", (*argv)[i], 12) == 0))
-           {
-             gchar *equal_pos = strchr ((*argv)[i], '=');
-             
-             if (equal_pos != NULL)
-               {
-                 gdk_debug_flags |= g_parse_debug_string (equal_pos+1,
-                                                          (GDebugKey *) gdk_debug_keys,
-                                                          gdk_ndebug_keys);
-               }
-             else if ((i + 1) < *argc && (*argv)[i + 1])
-               {
-                 gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
-                                                          (GDebugKey *) gdk_debug_keys,
-                                                          gdk_ndebug_keys);
-                 (*argv)[i] = NULL;
-                 i += 1;
-               }
-             (*argv)[i] = NULL;
-           }
-         else if ((strcmp ("--gdk-no-debug", (*argv)[i]) == 0) ||
-                  (strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0))
-           {
-             gchar *equal_pos = strchr ((*argv)[i], '=');
-             
-             if (equal_pos != NULL)
-               {
-                 gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1,
-                                                           (GDebugKey *) gdk_debug_keys,
-                                                           gdk_ndebug_keys);
-               }
-             else if ((i + 1) < *argc && (*argv)[i + 1])
-               {
-                 gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
-                                                           (GDebugKey *) gdk_debug_keys,
-                                                           gdk_ndebug_keys);
-                 (*argv)[i] = NULL;
-                 i += 1;
-               }
-             (*argv)[i] = NULL;
-           }
-         else 
-#endif /* G_ENABLE_DEBUG */
-           if (strcmp ("--display", (*argv)[i]) == 0)
-             {
-               (*argv)[i] = NULL;
-               
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   gdk_display_name = g_strdup ((*argv)[i + 1]);
-                   (*argv)[i + 1] = NULL;
-                   i += 1;
-                 }
-             }
-           else if (strcmp ("--sync", (*argv)[i]) == 0)
-             {
-               (*argv)[i] = NULL;
-               synchronize = TRUE;
-             }
-           else if (strcmp ("--no-xshm", (*argv)[i]) == 0)
-             {
-               (*argv)[i] = NULL;
-               gdk_use_xshm = FALSE;
-             }
-           else if (strcmp ("--name", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   g_set_prgname ((*argv)[i]);
-                   (*argv)[i] = NULL;
-                 }
-             }
-           else if (strcmp ("--class", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   gdk_progclass = (*argv)[i];
-                   (*argv)[i] = NULL;
-                 }
-             }
-#ifdef XINPUT_GXI
-           else if (strcmp ("--gxid_host", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   gdk_input_gxid_host = ((*argv)[i]);
-                   (*argv)[i] = NULL;
-                 }
-             }
-           else if (strcmp ("--gxid_port", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   gdk_input_gxid_port = atoi ((*argv)[i]);
-                   (*argv)[i] = NULL;
-                 }
-             }
-#endif
-#ifdef USE_XIM
-           else if (strcmp ("--xim-preedit", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   if (strcmp ("none", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
-                   else if (strcmp ("nothing", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
-                   else if (strcmp ("area", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
-                   else if (strcmp ("position", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
-                   else if (strcmp ("callbacks", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
-                   (*argv)[i] = NULL;
-                 }
-             }
-           else if (strcmp ("--xim-status", (*argv)[i]) == 0)
-             {
-               if ((i + 1) < *argc && (*argv)[i + 1])
-                 {
-                   (*argv)[i++] = NULL;
-                   if (strcmp ("none", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_STATUS_NONE);
-                   else if (strcmp ("nothing", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
-                   else if (strcmp ("area", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_STATUS_AREA);
-                   else if (strcmp ("callbacks", (*argv)[i]) == 0)
-                     gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
-                   (*argv)[i] = NULL;
-                 }
-             }
-#endif
-         
-         i += 1;
-       }
-      
-      for (i = 1; i < *argc; i++)
-       {
-         for (k = i; k < *argc; k++)
-           if ((*argv)[k] != NULL)
-             break;
-         
-         if (k > i)
-           {
-             k -= i;
-             for (j = i + k; j < *argc; j++)
-               (*argv)[j-k] = (*argv)[j];
-             *argc -= k;
-           }
-       }
-    }
-  else
-    {
-      g_set_prgname ("<unknown>");
-    }
-  
-  GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
-  
   gdk_display = XOpenDisplay (gdk_display_name);
   if (!gdk_display)
     return FALSE;
   
-  if (synchronize)
+  if (gdk_synchronize)
     XSynchronize (gdk_display, True);
   
   gdk_screen = DefaultScreen (gdk_display);
@@ -378,14 +173,10 @@ gdk_init_check (int        *argc,
     }
   class_hint->res_class = gdk_progclass;
   XmbSetWMProperties (gdk_display, gdk_leader_window,
-                      NULL, NULL, argv_orig, argc_orig
+                      NULL, NULL, argv, argc
                       NULL, NULL, class_hint);
   XFree (class_hint);
   
-  for (i = 0; i < argc_orig; i++)
-    g_free(argv_orig[i]);
-  g_free(argv_orig);
-  
   gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", False);
   gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", False);
   gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", False);
@@ -396,61 +187,9 @@ gdk_init_check (int         *argc,
   XGetKeyboardControl (gdk_display, &keyboard_state);
   autorepeat = keyboard_state.global_auto_repeat;
   
-  g_atexit (gdk_exit_func);
-  
-  gdk_events_init ();
-  gdk_visual_init ();
-  gdk_window_init ();
-  gdk_image_init ();
-  gdk_input_init ();
-  gdk_dnd_init ();
-
-#ifdef USE_XIM
-  gdk_im_open ();
-#endif
-  
-  gdk_initialized = 1;
-
   return TRUE;
 }
 
-void
-gdk_init (int *argc, char ***argv)
-{
-  if (!gdk_init_check (argc, argv))
-    {
-      g_warning ("cannot open display: %s", gdk_get_display ());
-      exit(1);
-    }
-}
-
-/*
- *--------------------------------------------------------------
- * gdk_exit
- *
- *   Restores the library to an un-itialized state and exits
- *   the program using the "exit" system call.
- *
- * Arguments:
- *   "errorcode" is the error value to pass to "exit".
- *
- * Results:
- *   Allocated structures are freed and the program exits
- *   cleanly.
- *
- * Side effects:
- *
- *--------------------------------------------------------------
- */
-
-void
-gdk_exit (gint errorcode)
-{
-  /* de-initialisation is done by the gdk_exit_funct(),
-     no need to do this here (Alex J.) */
-  exit (errorcode);
-}
-
 void
 gdk_set_use_xshm (gint use_xshm)
 {
@@ -822,50 +561,10 @@ gdk_beep (void)
   XBell(gdk_display, 0);
 }
 
-/*
- *--------------------------------------------------------------
- * gdk_exit_func
- *
- *   This is the "atexit" function that makes sure the
- *   library gets a chance to cleanup.
- *
- * Arguments:
- *
- * Results:
- *
- * Side effects:
- *   The library is un-initialized and the program exits.
- *
- *--------------------------------------------------------------
- */
-
-static void
-gdk_exit_func (void)
+void
+gdk_windowing_exit (void)
 {
-  static gboolean in_gdk_exit_func = FALSE;
-  
-  /* This is to avoid an infinite loop if a program segfaults in
-     an atexit() handler (and yes, it does happen, especially if a program
-     has trounced over memory too badly for even g_message to work) */
-  if (in_gdk_exit_func == TRUE)
-    return;
-  in_gdk_exit_func = TRUE;
-  
-  if (gdk_initialized)
-    {
-#ifdef USE_XIM
-      /* cleanup IC */
-      gdk_ic_cleanup ();
-      /* close IM */
-      gdk_im_close ();
-#endif
-      gdk_image_exit ();
-      gdk_input_exit ();
-      gdk_key_repeat_restore ();
-      
-      XCloseDisplay (gdk_display);
-      gdk_initialized = 0;
-    }
+  XCloseDisplay (gdk_display);
 }
 
 /*
@@ -977,77 +676,6 @@ gdk_get_display (void)
   return (gchar *)XDisplayName (gdk_display_name);
 }
 
-/*************************************************************
- * gdk_error_trap_push:
- *     Push an error trap. X errors will be trapped until
- *     the corresponding gdk_error_pop(), which will return
- *     the error code, if any.
- *   arguments:
- *     
- *   results:
- *************************************************************/
-
-void
-gdk_error_trap_push (void)
-{
-  GSList *node;
-  GdkErrorTrap *trap;
-
-  if (gdk_error_trap_free_list)
-    {
-      node = gdk_error_trap_free_list;
-      gdk_error_trap_free_list = gdk_error_trap_free_list->next;
-    }
-  else
-    {
-      node = g_slist_alloc ();
-      node->data = g_new (GdkErrorTrap, 1);
-    }
-
-  node->next = gdk_error_traps;
-  gdk_error_traps = node;
-  
-  trap = node->data;
-  trap->error_code = gdk_error_code;
-  trap->error_warnings = gdk_error_warnings;
-
-  gdk_error_code = 0;
-  gdk_error_warnings = 0;
-}
-
-/*************************************************************
- * gdk_error_trap_pop:
- *     Pop an error trap added with gdk_error_push()
- *   arguments:
- *     
- *   results:
- *     0, if no error occured, otherwise the error code.
- *************************************************************/
-
-gint
-gdk_error_trap_pop (void)
-{
-  GSList *node;
-  GdkErrorTrap *trap;
-  gint result;
-
-  g_return_val_if_fail (gdk_error_traps != NULL, 0);
-
-  node = gdk_error_traps;
-  gdk_error_traps = gdk_error_traps->next;
-
-  node->next = gdk_error_trap_free_list;
-  gdk_error_trap_free_list = node;
-  
-  result = gdk_error_code;
-  
-  trap = node->data;
-  gdk_error_code = trap->error_code;
-  gdk_error_warnings = trap->error_warnings;
-  
-  return result;
-}
-
 gint 
 gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
                 XEvent *event_send)
@@ -1065,138 +693,6 @@ gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
   return result && !gdk_error_code;
 }
 
-#ifndef HAVE_XCONVERTCASE
-/* compatibility function from X11R6.3, since XConvertCase is not
- * supplied by X11R5.
- */
-static void
-gdkx_XConvertCase (KeySym symbol,
-                  KeySym *lower,
-                  KeySym *upper)
-{
-  register KeySym sym = symbol;
-  
-  g_return_if_fail (lower != NULL);
-  g_return_if_fail (upper != NULL);
-  
-  *lower = sym;
-  *upper = sym;
-  
-  switch (sym >> 8)
-    {
-#if    defined (GDK_A) && defined (GDK_Ooblique)
-    case 0: /* Latin 1 */
-      if ((sym >= GDK_A) && (sym <= GDK_Z))
-       *lower += (GDK_a - GDK_A);
-      else if ((sym >= GDK_a) && (sym <= GDK_z))
-       *upper -= (GDK_a - GDK_A);
-      else if ((sym >= GDK_Agrave) && (sym <= GDK_Odiaeresis))
-       *lower += (GDK_agrave - GDK_Agrave);
-      else if ((sym >= GDK_agrave) && (sym <= GDK_odiaeresis))
-       *upper -= (GDK_agrave - GDK_Agrave);
-      else if ((sym >= GDK_Ooblique) && (sym <= GDK_Thorn))
-       *lower += (GDK_oslash - GDK_Ooblique);
-      else if ((sym >= GDK_oslash) && (sym <= GDK_thorn))
-       *upper -= (GDK_oslash - GDK_Ooblique);
-      break;
-#endif /* LATIN1 */
-      
-#if    defined (GDK_Aogonek) && defined (GDK_tcedilla)
-    case 1: /* Latin 2 */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym == GDK_Aogonek)
-       *lower = GDK_aogonek;
-      else if (sym >= GDK_Lstroke && sym <= GDK_Sacute)
-       *lower += (GDK_lstroke - GDK_Lstroke);
-      else if (sym >= GDK_Scaron && sym <= GDK_Zacute)
-       *lower += (GDK_scaron - GDK_Scaron);
-      else if (sym >= GDK_Zcaron && sym <= GDK_Zabovedot)
-       *lower += (GDK_zcaron - GDK_Zcaron);
-      else if (sym == GDK_aogonek)
-       *upper = GDK_Aogonek;
-      else if (sym >= GDK_lstroke && sym <= GDK_sacute)
-       *upper -= (GDK_lstroke - GDK_Lstroke);
-      else if (sym >= GDK_scaron && sym <= GDK_zacute)
-       *upper -= (GDK_scaron - GDK_Scaron);
-      else if (sym >= GDK_zcaron && sym <= GDK_zabovedot)
-       *upper -= (GDK_zcaron - GDK_Zcaron);
-      else if (sym >= GDK_Racute && sym <= GDK_Tcedilla)
-       *lower += (GDK_racute - GDK_Racute);
-      else if (sym >= GDK_racute && sym <= GDK_tcedilla)
-       *upper -= (GDK_racute - GDK_Racute);
-      break;
-#endif /* LATIN2 */
-      
-#if    defined (GDK_Hstroke) && defined (GDK_Cabovedot)
-    case 2: /* Latin 3 */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym >= GDK_Hstroke && sym <= GDK_Hcircumflex)
-       *lower += (GDK_hstroke - GDK_Hstroke);
-      else if (sym >= GDK_Gbreve && sym <= GDK_Jcircumflex)
-       *lower += (GDK_gbreve - GDK_Gbreve);
-      else if (sym >= GDK_hstroke && sym <= GDK_hcircumflex)
-       *upper -= (GDK_hstroke - GDK_Hstroke);
-      else if (sym >= GDK_gbreve && sym <= GDK_jcircumflex)
-       *upper -= (GDK_gbreve - GDK_Gbreve);
-      else if (sym >= GDK_Cabovedot && sym <= GDK_Scircumflex)
-       *lower += (GDK_cabovedot - GDK_Cabovedot);
-      else if (sym >= GDK_cabovedot && sym <= GDK_scircumflex)
-       *upper -= (GDK_cabovedot - GDK_Cabovedot);
-      break;
-#endif /* LATIN3 */
-      
-#if    defined (GDK_Rcedilla) && defined (GDK_Amacron)
-    case 3: /* Latin 4 */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym >= GDK_Rcedilla && sym <= GDK_Tslash)
-       *lower += (GDK_rcedilla - GDK_Rcedilla);
-      else if (sym >= GDK_rcedilla && sym <= GDK_tslash)
-       *upper -= (GDK_rcedilla - GDK_Rcedilla);
-      else if (sym == GDK_ENG)
-       *lower = GDK_eng;
-      else if (sym == GDK_eng)
-       *upper = GDK_ENG;
-      else if (sym >= GDK_Amacron && sym <= GDK_Umacron)
-       *lower += (GDK_amacron - GDK_Amacron);
-      else if (sym >= GDK_amacron && sym <= GDK_umacron)
-       *upper -= (GDK_amacron - GDK_Amacron);
-      break;
-#endif /* LATIN4 */
-      
-#if    defined (GDK_Serbian_DJE) && defined (GDK_Cyrillic_yu)
-    case 6: /* Cyrillic */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym >= GDK_Serbian_DJE && sym <= GDK_Serbian_DZE)
-       *lower -= (GDK_Serbian_DJE - GDK_Serbian_dje);
-      else if (sym >= GDK_Serbian_dje && sym <= GDK_Serbian_dze)
-       *upper += (GDK_Serbian_DJE - GDK_Serbian_dje);
-      else if (sym >= GDK_Cyrillic_YU && sym <= GDK_Cyrillic_HARDSIGN)
-       *lower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
-      else if (sym >= GDK_Cyrillic_yu && sym <= GDK_Cyrillic_hardsign)
-       *upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
-      break;
-#endif /* CYRILLIC */
-      
-#if    defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma)
-    case 7: /* Greek */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (sym >= GDK_Greek_ALPHAaccent && sym <= GDK_Greek_OMEGAaccent)
-       *lower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
-      else if (sym >= GDK_Greek_alphaaccent && sym <= GDK_Greek_omegaaccent &&
-              sym != GDK_Greek_iotaaccentdieresis &&
-              sym != GDK_Greek_upsilonaccentdieresis)
-       *upper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
-      else if (sym >= GDK_Greek_ALPHA && sym <= GDK_Greek_OMEGA)
-       *lower += (GDK_Greek_alpha - GDK_Greek_ALPHA);
-      else if (sym >= GDK_Greek_alpha && sym <= GDK_Greek_omega &&
-              sym != GDK_Greek_finalsmallsigma)
-       *upper -= (GDK_Greek_alpha - GDK_Greek_ALPHA);
-      break;
-#endif /* GREEK */
-    }
-}
-#endif
-
 gchar*
 gdk_keyval_name (guint       keyval)
 {
@@ -1211,71 +707,21 @@ gdk_keyval_from_name (const gchar *keyval_name)
   return XStringToKeysym (keyval_name);
 }
 
-guint
-gdk_keyval_to_upper (guint       keyval)
-{
-  if (keyval)
-    {
-      KeySym lower_val = 0;
-      KeySym upper_val = 0;
-      
-      XConvertCase (keyval, &lower_val, &upper_val);
-      return upper_val;
-    }
-  return 0;
-}
-
-guint
-gdk_keyval_to_lower (guint       keyval)
-{
-  if (keyval)
-    {
-      KeySym lower_val = 0;
-      KeySym upper_val = 0;
-      
-      XConvertCase (keyval, &lower_val, &upper_val);
-      return lower_val;
-    }
-  return 0;
-}
-
-gboolean
-gdk_keyval_is_upper (guint       keyval)
-{
-  if (keyval)
-    {
-      KeySym lower_val = 0;
-      KeySym upper_val = 0;
-      
-      XConvertCase (keyval, &lower_val, &upper_val);
-      return upper_val == keyval;
-    }
-  return TRUE;
-}
-
-gboolean
-gdk_keyval_is_lower (guint       keyval)
-{
-  if (keyval)
-    {
-      KeySym lower_val = 0;
-      KeySym upper_val = 0;
-      
-      XConvertCase (keyval, &lower_val, &upper_val);
-      return lower_val == keyval;
-    }
-  return TRUE;
-}
-
-void
-gdk_threads_enter ()
-{
-  GDK_THREADS_ENTER ();
-}
-
+#ifdef HAVE_XCONVERTCASE
 void
-gdk_threads_leave ()
-{
-  GDK_THREADS_LEAVE ();
-}
-
+gdk_keyval_convert_case (guint symbol,
+                        guint *lower,
+                        guint *upper)
+{
+  KeySym xlower = 0;
+  KeySym xupper = 0;
+
+  if (symbol)
+    XConvertCase (symbol, &xlower, &xupper);
+
+  if (lower)
+    *lower = xlower;
+  if (upper)
+    *upper = xupper;
+}  
+#endif HAVE_XCONVERTCASE
index 8ee69db9cd1ab5c706fa3171d62581ce8cd11c23..c27517c9a3a99fd15a753ed455f096570883ec50 100644 (file)
@@ -50,6 +50,44 @@ typedef struct
   gulong pixels[1];
 } _GdkPixmapInfo;
 
+GdkDrawableClass _gdk_x11_pixmap_class;
+
+static void
+gdk_x11_pixmap_destroy (GdkPixmap *pixmap)
+{
+  XFreePixmap (GDK_DRAWABLE_XDISPLAY (pixmap), GDK_DRAWABLE_XID (pixmap));
+  gdk_xid_table_remove (GDK_DRAWABLE_XID (pixmap));
+
+  g_free (GDK_DRAWABLE_XDATA (pixmap));
+}
+
+static GdkDrawable *
+gdk_x11_pixmap_alloc (void)
+{
+  GdkDrawable *drawable;
+  GdkDrawablePrivate *private;
+  
+  static GdkDrawableClass klass;
+  static gboolean initialized = FALSE;
+
+  if (!initialized)
+    {
+      initialized = TRUE;
+      
+      klass = _gdk_x11_drawable_class;
+      klass.destroy = gdk_x11_pixmap_destroy;
+    }
+
+  drawable = gdk_drawable_alloc ();
+  private = (GdkDrawablePrivate *)drawable;
+
+  private->klass = &klass;
+  private->klass_data = g_new (GdkDrawableXData, 1);
+  private->window_type = GDK_DRAWABLE_PIXMAP;
+
+  return drawable;
+}
+
 GdkPixmap*
 gdk_pixmap_new (GdkWindow *window,
                gint       width,
@@ -62,9 +100,9 @@ gdk_pixmap_new (GdkWindow *window,
   g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
   g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
   g_return_val_if_fail ((width != 0) && (height != 0), NULL);
-
+  
   if (!window)
-    window = (GdkWindow*) &gdk_root_parent;
+    window = gdk_parent_root;
 
   if (GDK_DRAWABLE_DESTROYED (window))
     return NULL;
@@ -72,21 +110,17 @@ gdk_pixmap_new (GdkWindow *window,
   if (depth == -1)
     depth = gdk_drawable_get_visual (window)->depth;
 
-  private = g_new0 (GdkDrawablePrivate, 1);
-  pixmap = (GdkPixmap*) private;
+  pixmap = gdk_x11_pixmap_alloc ();
+  private = (GdkDrawablePrivate *)pixmap;
 
-  private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
-  private->window_type = GDK_DRAWABLE_PIXMAP;
-  private->xwindow = XCreatePixmap (private->xdisplay,
-                                   GDK_DRAWABLE_XID (window),
-                                   width, height, depth);
-  private->colormap = NULL;
+  GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
+  GDK_DRAWABLE_XDATA (private)->xid = XCreatePixmap (GDK_DRAWABLE_XDISPLAY (pixmap),
+                                                    GDK_DRAWABLE_XID (window),
+                                                    width, height, depth);
   private->width = width;
   private->height = height;
-  private->ref_count = 1;
-  private->destroyed = 0;
 
-  gdk_xid_table_insert (&private->xwindow, pixmap);
+  gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap);
 
   return pixmap;
 }
@@ -105,26 +139,23 @@ gdk_bitmap_create_from_data (GdkWindow   *window,
   g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
 
   if (!window)
-    window = (GdkWindow*) &gdk_root_parent;
+    window = gdk_parent_root;
 
   if (GDK_DRAWABLE_DESTROYED (window))
     return NULL;
 
-  private = g_new0 (GdkDrawablePrivate, 1);
-  pixmap = (GdkPixmap*) private;
+  pixmap = gdk_x11_pixmap_alloc ();
+  private = (GdkDrawablePrivate *)pixmap;
 
-  private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
-  private->window_type = GDK_DRAWABLE_PIXMAP;
   private->width = width;
   private->height = height;
-  private->ref_count = 1;
-  private->destroyed = FALSE;
 
-  private->xwindow = XCreateBitmapFromData (private->xdisplay,
-                                           GDK_DRAWABLE_XID (window),
-                                           (char *)data, width, height);
+  GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
+  GDK_DRAWABLE_XDATA (private)->xid = XCreateBitmapFromData (GDK_DRAWABLE_XDISPLAY (window),
+                                                            GDK_DRAWABLE_XID (window),
+                                                            (char *)data, width, height);
 
-  gdk_xid_table_insert (&private->xwindow, pixmap);
+  gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap);
 
   return pixmap;
 }
@@ -149,7 +180,7 @@ gdk_pixmap_create_from_data (GdkWindow   *window,
   g_return_val_if_fail ((width != 0) && (height != 0), NULL);
 
   if (!window)
-    window = (GdkWindow*) &gdk_root_parent;
+    window = gdk_parent_root;
 
   if (GDK_DRAWABLE_DESTROYED (window))
     return NULL;
@@ -157,22 +188,19 @@ gdk_pixmap_create_from_data (GdkWindow   *window,
   if (depth == -1)
     depth = gdk_drawable_get_visual (window)->depth;
 
-  private = g_new0 (GdkDrawablePrivate, 1);
-  pixmap = (GdkPixmap*) private;
+  pixmap = gdk_x11_pixmap_alloc ();
+  private = (GdkDrawablePrivate *)pixmap;
 
-  private->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
-  private->window_type = GDK_DRAWABLE_PIXMAP;
   private->width = width;
   private->height = height;
-  private->ref_count = 1;
-  private->destroyed = FALSE;
 
-  private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay,
-                                                 GDK_DRAWABLE_XID (window),
-                                                 (char *)data, width, height,
-                                                 fg->pixel, bg->pixel, depth);
+  GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DRAWABLE_XDISPLAY (window);
+  GDK_DRAWABLE_XDATA (private)->xid = XCreatePixmapFromBitmapData (GDK_DRAWABLE_XDISPLAY (window),
+                                                                  GDK_DRAWABLE_XID (window),
+                                                                  (char *)data, width, height,
+                                                                  fg->pixel, bg->pixel, depth);
 
-  gdk_xid_table_insert (&private->xwindow, pixmap);
+  gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap);
 
   return pixmap;
 }
@@ -443,7 +471,7 @@ _gdk_pixmap_create_from_xpm (GdkWindow  *window,
     g_warning ("Creating pixmap from xpm with NULL window and colormap");
   
   if (window == NULL)
-    window = (GdkWindow *)&gdk_root_parent;
+    window = gdk_parent_root;
   
   if (colormap == NULL)
     {
@@ -588,7 +616,7 @@ _gdk_pixmap_create_from_xpm (GdkWindow  *window,
  error:
   
   if (mask)
-    gdk_gc_destroy (gc);
+    gdk_gc_unref (gc);
   
   if (image != NULL)
     {
@@ -601,8 +629,8 @@ _gdk_pixmap_create_from_xpm (GdkWindow  *window,
       gc = gdk_gc_new (pixmap);
       gdk_gc_set_foreground (gc, transparent_color);
       gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
-      gdk_gc_destroy (gc);
-      gdk_image_destroy (image);
+      gdk_gc_unref (gc);
+      gdk_image_unref (image);
     }
   else if (color_info)
     gdk_xpm_destroy_notify (color_info);
@@ -766,61 +794,16 @@ gdk_pixmap_foreign_new (guint32 anid)
                    &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
       return NULL;
       
-  /* allocate a new gdk pixmap */
-  private = g_new(GdkDrawablePrivate, 1);
-  pixmap = (GdkPixmap *)private;
+  pixmap = gdk_x11_pixmap_alloc ();
+  private = (GdkDrawablePrivate *)pixmap;
+
+  GDK_DRAWABLE_XDATA (private)->xdisplay = GDK_DISPLAY ();
+  GDK_DRAWABLE_XDATA (private)->xid = xpixmap;
 
-  private->xdisplay = GDK_DISPLAY();
-  private->window_type = GDK_DRAWABLE_PIXMAP;
-  private->xwindow = xpixmap;
-  private->colormap = NULL;
   private->width = w_ret;
   private->height = h_ret;
-  private->ref_count = 1;
-  private->destroyed = 0;
   
-  gdk_xid_table_insert(&private->xwindow, pixmap);
+  gdk_xid_table_insert(&GDK_DRAWABLE_XID (pixmap), pixmap);
 
   return pixmap;
 }
-
-GdkPixmap*
-gdk_pixmap_ref (GdkPixmap *pixmap)
-{
-  GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap;
-  g_return_val_if_fail (pixmap != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_PIXMAP (private), NULL);
-
-  private->ref_count += 1;
-  return pixmap;
-}
-
-void
-gdk_pixmap_unref (GdkPixmap *pixmap)
-{
-  GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap;
-  g_return_if_fail (pixmap != NULL);
-  g_return_if_fail (GDK_IS_PIXMAP (private));
-  g_return_if_fail (private->ref_count > 0);
-
-  private->ref_count -= 1;
-  if (private->ref_count == 0)
-    {
-      XFreePixmap (private->xdisplay, private->xwindow);
-      gdk_xid_table_remove (private->xwindow);
-      g_dataset_destroy (private);
-      g_free (private);
-    }
-}
-
-GdkBitmap *
-gdk_bitmap_ref (GdkBitmap *bitmap)
-{
-  return (GdkBitmap *)gdk_pixmap_ref ((GdkPixmap *)bitmap);
-}
-
-void
-gdk_bitmap_unref (GdkBitmap *bitmap)
-{
-  gdk_pixmap_unref ((GdkPixmap *)bitmap);
-}
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
new file mode 100644 (file)
index 0000000..27d3451
--- /dev/null
@@ -0,0 +1,158 @@
+#ifndef __GDK_PRIVATE_X11_H__
+#define __GDK_PRIVATE_X11_H__
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <gdk/gdkfont.h>
+#include <gdk/gdkprivate.h>
+#include <gdk/gdkcursor.h>
+
+typedef struct _GdkGCXData          GdkGCXData;
+typedef struct _GdkDrawableXData    GdkDrawableXData;
+typedef struct _GdkColormapPrivateX GdkColormapPrivateX;
+typedef struct _GdkCursorPrivate    GdkCursorPrivate;
+typedef struct _GdkFontPrivateX     GdkFontPrivateX;
+typedef struct _GdkImagePrivateX    GdkImagePrivateX;
+typedef struct _GdkVisualPrivate    GdkVisualPrivate;
+typedef struct _GdkRegionPrivate    GdkRegionPrivate;
+
+#ifdef USE_XIM
+typedef struct _GdkICPrivate        GdkICPrivate;
+#endif /* USE_XIM */
+
+#define GDK_DRAWABLE_XDATA(win) ((GdkDrawableXData *)(((GdkDrawablePrivate*)(win))->klass_data))
+#define GDK_GC_XDATA(gc) ((GdkGCXData *)(((GdkGCPrivate*)(gc))->klass_data))
+
+struct _GdkGCXData
+{
+  GC xgc;
+  Display *xdisplay;
+};
+
+struct _GdkDrawableXData
+{
+  Window xid;
+  Display *xdisplay;
+};
+
+struct _GdkCursorPrivate
+{
+  GdkCursor cursor;
+  Cursor xcursor;
+  Display *xdisplay;
+};
+
+struct _GdkFontPrivateX
+{
+  GdkFontPrivate base;
+  /* XFontStruct *xfont; */
+  /* generic pointer point to XFontStruct or XFontSet */
+  gpointer xfont;
+  Display *xdisplay;
+
+  GSList *names;
+};
+
+struct _GdkVisualPrivate
+{
+  GdkVisual visual;
+  Visual *xvisual;
+};
+
+struct _GdkColormapPrivateX
+{
+  GdkColormapPrivate base;
+
+  Colormap xcolormap;
+  Display *xdisplay;
+  gint private_val;
+
+  GHashTable *hash;
+  GdkColorInfo *info;
+  time_t last_sync_time;
+};
+
+struct _GdkImagePrivateX
+{
+  GdkImagePrivate base;
+  
+  XImage *ximage;
+  Display *xdisplay;
+  gpointer x_shm_info;
+};
+
+struct _GdkRegionPrivate
+{
+  GdkRegion region;
+  Region xregion;
+};
+
+
+#ifdef USE_XIM
+
+struct _GdkICPrivate
+{
+  XIC xic;
+  GdkICAttr *attr;
+  GdkICAttributesType mask;
+};
+
+#endif /* USE_XIM */
+
+void          gdk_xid_table_insert     (XID             *xid,
+                                       gpointer         data);
+void          gdk_xid_table_remove     (XID              xid);
+gpointer      gdk_xid_table_lookup     (XID              xid);
+gint          gdk_send_xevent          (Window           window,
+                                       gboolean         propagate,
+                                       glong            event_mask,
+                                       XEvent          *event_send);
+GdkGC *       _gdk_x11_gc_new          (GdkDrawable     *drawable,
+                                       GdkGCValues     *values,
+                                       GdkGCValuesMask  values_mask);
+GdkColormap * gdk_colormap_lookup      (Colormap         xcolormap);
+GdkVisual *   gdk_visual_lookup        (Visual          *xvisual);
+
+/* Please see gdkwindow.c for comments on how to use */ 
+Window gdk_window_xid_at        (Window    base,
+                                gint      bx,
+                                gint      by,
+                                gint      x,
+                                gint      y,
+                                GList    *excludes,
+                                gboolean  excl_child);
+Window gdk_window_xid_at_coords (gint      x,
+                                gint      y,
+                                GList    *excludes,
+                                gboolean  excl_child);
+
+extern GdkDrawableClass  _gdk_x11_drawable_class;
+extern gboolean                 gdk_use_xshm;
+extern gchar           *gdk_display_name;
+extern Display         *gdk_display;
+extern Window           gdk_root_window;
+extern Window           gdk_leader_window;
+extern Atom             gdk_wm_delete_window;
+extern Atom             gdk_wm_take_focus;
+extern Atom             gdk_wm_protocols;
+extern Atom             gdk_wm_window_protocols[];
+extern Atom             gdk_selection_property;
+extern GdkWindow       *selection_owner[];
+extern gchar           *gdk_progclass;
+extern gboolean          gdk_null_window_warnings;
+extern const int         gdk_nevent_masks;
+extern const int         gdk_event_mask_table[];
+
+extern GdkWindowPrivate *gdk_xgrab_window;  /* Window that currently holds the
+                                            * x pointer grab
+                                            */
+
+#ifdef USE_XIM
+extern GdkICPrivate *gdk_xim_ic;               /* currently using IC */
+extern GdkWindow *gdk_xim_window;              /* currently using Window */
+#endif /* USE_XIM */
+
+
+#endif /* __GDK_PRIVATE_X11_H__ */
+
index b91b787d1bb9c9c4252118a8fa493fe2a7123470..ee270b1e74678b3984ba0ef7af829ba7ca0731e2 100644 (file)
@@ -39,6 +39,8 @@ gdk_atom_intern (const gchar *atom_name,
   GdkAtom retval;
   static GHashTable *atom_hash = NULL;
   
+  g_return_val_if_fail (atom_name != NULL, GDK_NONE);
+
   if (!atom_hash)
     atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
 
@@ -110,13 +112,16 @@ gdk_property_get (GdkWindow   *window,
   gulong ret_length;
   guchar *ret_data;
 
+  g_return_val_if_fail (window != NULL, FALSE);
+  g_return_val_if_fail (!GDK_IS_WINDOW (window), FALSE);
+
   if (window)
     {
       if (GDK_DRAWABLE_DESTROYED (window))
        return FALSE;
 
-      xdisplay = GDK_WINDOW_XDISPLAY (window);
-      xwindow = GDK_WINDOW_XWINDOW (window);
+      xdisplay = GDK_DRAWABLE_XDISPLAY (window);
+      xwindow = GDK_DRAWABLE_XID (window);
     }
   else
     {
@@ -196,13 +201,16 @@ gdk_property_change (GdkWindow   *window,
   Display *xdisplay;
   Window xwindow;
 
+  g_return_if_fail (window != NULL);
+  g_return_if_fail (!GDK_IS_WINDOW (window));
+
   if (window)
     {
       if (GDK_DRAWABLE_DESTROYED (window))
        return;
 
-      xdisplay = GDK_WINDOW_XDISPLAY (window);
-      xwindow = GDK_WINDOW_XWINDOW (window);
+      xdisplay = GDK_DRAWABLE_XDISPLAY (window);
+      xwindow = GDK_DRAWABLE_XID (window);
     }
   else
     {
@@ -221,13 +229,16 @@ gdk_property_delete (GdkWindow *window,
   Display *xdisplay;
   Window xwindow;
 
+  g_return_if_fail (window != NULL);
+  g_return_if_fail (!GDK_IS_WINDOW (window));
+
   if (window)
     {
       if (GDK_DRAWABLE_DESTROYED (window))
        return;
 
-      xdisplay = GDK_WINDOW_XDISPLAY (window);
-      xwindow = GDK_WINDOW_XWINDOW (window);
+      xdisplay = GDK_DRAWABLE_XDISPLAY (window);
+      xwindow = GDK_DRAWABLE_XID (window);
     }
   else
     {
index d09f38865d3c8ef50114997512f5c804135bde65..b21aba8938ed5a029ed069c3f33b402b7298fee3 100644 (file)
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
-#include "gdk.h"
-#include "gdkprivate.h"
-
-
-
+#include "gdkprivate-x11.h"
 
 GdkRegion*
 gdk_region_new (void)
index 072ff456e56a45ef12a382d8c13f0dca2c7f65e2..bb007d4a9bddcccec276ec29b88f7fdb6c54a30f 100644 (file)
@@ -28,7 +28,7 @@
 #include <X11/Xutil.h>
 
 #include "gdkvisual.h"
-#include "gdkprivate.h"
+#include "gdkprivate-x11.h"
 
 static void  gdk_visual_add            (GdkVisual *visual);
 static void  gdk_visual_decompose_mask (gulong     mask,
index 16bdb37d7ce8e77ee25b19c7ccb9bfc0670dab76..74cf7d953d046dfd0a5bbce77de564caf88a1629 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "gdkwindow.h"
 #include "gdkinputprivate.h"
-#include "gdkprivate.h"
+#include "gdkprivate-x11.h"
 #include "gdkx.h"
 #include "MwmUtil.h"
 
@@ -77,144 +77,50 @@ static void     gdk_window_set_static_win_gravity (GdkWindow *window,
                                                   gboolean   on);
 static gboolean gdk_window_have_shape_ext (void);
 
-/* internal function created for and used by gdk_window_xid_at_coords */
-Window
-gdk_window_xid_at (Window   base,
-                  gint     bx,
-                  gint     by,
-                  gint     x,
-                  gint     y, 
-                  GList   *excludes,
-                  gboolean excl_child)
+static void
+gdk_x11_window_destroy (GdkDrawable *drawable)
 {
-  GdkWindow *window;
-  GdkDrawablePrivate *private;
-  Display *disp;
-  Window *list = NULL;
-  Window child = 0, parent_win = 0, root_win = 0;
-  int i;
-  unsigned int ww, wh, wb, wd, num;
-  int wx, wy;
-  
-  window = (GdkWindow*) &gdk_root_parent;
-  private = (GdkDrawablePrivate*) window;
-  disp = private->xdisplay;
-  if (!XGetGeometry (disp, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd))
-    return 0;
-  wx += bx;
-  wy += by;
-  
-  if (!((x >= wx) &&
-       (y >= wy) &&
-       (x < (int) (wx + ww)) &&
-       (y < (int) (wy + wh))))
-    return 0;
-  
-  if (!XQueryTree (disp, base, &root_win, &parent_win, &list, &num))
-    return base;
-  
-  if (list)
+  if (!GDK_DRAWABLE_DESTROYED (drawable))
     {
-      for (i = num - 1; ; i--)
-       {
-         if ((!excl_child) || (!g_list_find (excludes, (gpointer *) list[i])))
-           {
-             if ((child = gdk_window_xid_at (list[i], wx, wy, x, y, excludes, excl_child)) != 0)
-               {
-                 XFree (list);
-                 return child;
-               }
-           }
-         if (!i)
-           break;
-       }
-      XFree (list);
+      if (GDK_DRAWABLE_TYPE (drawable) == GDK_WINDOW_FOREIGN)
+       gdk_xid_table_remove (GDK_DRAWABLE_XID (drawable));
+      else
+       g_warning ("losing last reference to undestroyed window\n");
     }
-  return base;
+
+  g_free (GDK_DRAWABLE_XDATA (drawable));
 }
 
-/* 
- * The following fucntion by The Rasterman <raster@redhat.com>
- * This function returns the X Window ID in which the x y location is in 
- * (x and y being relative to the root window), excluding any windows listed
- * in the GList excludes (this is a list of X Window ID's - gpointer being
- * the Window ID).
- * 
- * This is primarily designed for internal gdk use - for DND for example
- * when using a shaped icon window as the drag object - you exclude the
- * X Window ID of the "icon" (perhaps more if excludes may be needed) and
- * You can get back an X Window ID as to what X Window ID is infact under
- * those X,Y co-ordinates.
- */
-Window
-gdk_window_xid_at_coords (gint     x,
-                         gint     y,
-                         GList   *excludes,
-                         gboolean excl_child)
+static GdkWindow *
+gdk_x11_window_alloc (void)
 {
   GdkWindow *window;
-  GdkDrawablePrivate *private;
-  Display *disp;
-  Window *list = NULL;
-  Window root, child = 0, parent_win = 0, root_win = 0;
-  unsigned int num;
-  int i;
-
-  window = (GdkWindow*) &gdk_root_parent;
-  private = (GdkDrawablePrivate*) window;
-  disp = private->xdisplay;
-  root = private->xwindow;
-  num = g_list_length (excludes);
+  GdkWindowPrivate *private;
   
-  XGrabServer (disp);
-  if (!XQueryTree (disp, root, &root_win, &parent_win, &list, &num))
-    {
-      XUngrabServer (disp);
-      return root;
-    }
-  if (list)
+  static GdkDrawableClass klass;
+  static gboolean initialized = FALSE;
+
+  if (!initialized)
     {
-      i = num - 1;
-      do
-       {
-         XWindowAttributes xwa;
-         
-         XGetWindowAttributes (disp, list [i], &xwa);
-         
-         if (xwa.map_state != IsViewable)
-           continue;
-         
-         if (excl_child && g_list_find (excludes, (gpointer *) list[i]))
-           continue;
-         
-         if ((child = gdk_window_xid_at (list[i], 0, 0, x, y, excludes, excl_child)) == 0)
-           continue;
-         
-         if (excludes)
-           {
-             if (!g_list_find (excludes, (gpointer *) child))
-               {
-                 XFree (list);
-                 XUngrabServer (disp);
-                 return child;
-               }
-           }
-         else
-           {
-             XFree (list);
-             XUngrabServer (disp);
-             return child;
-           }
-       } while (--i > 0);
-      XFree (list);
+      initialized = TRUE;
+      
+      klass = _gdk_x11_drawable_class;
+      klass.destroy = gdk_x11_window_destroy;
     }
-  XUngrabServer (disp);
-  return root;
+
+  window = _gdk_window_alloc ();
+  private = (GdkWindowPrivate *)window;
+
+  private->drawable.klass = &klass;
+  private->drawable.klass_data = g_new (GdkDrawableXData, 1);
+
+  return window;
 }
 
 void
 gdk_window_init (void)
 {
+  GdkWindowPrivate *private;
   XWindowAttributes xattributes;
   unsigned int width;
   unsigned int height;
@@ -225,18 +131,18 @@ gdk_window_init (void)
   XGetGeometry (gdk_display, gdk_root_window, &gdk_root_window,
                &x, &y, &width, &height, &border_width, &depth);
   XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes);
+
+  gdk_parent_root = gdk_x11_window_alloc ();
+  private = (GdkWindowPrivate *)gdk_parent_root;
+  
+  GDK_DRAWABLE_XDATA (gdk_parent_root)->xdisplay = gdk_display;
+  GDK_DRAWABLE_XDATA (gdk_parent_root)->xid = gdk_root_window;
+
+  private->drawable.window_type = GDK_WINDOW_ROOT;
+  private->drawable.width = width;
+  private->drawable.height = height;
   
-  gdk_root_parent.drawable.xwindow = gdk_root_window;
-  gdk_root_parent.drawable.xdisplay = gdk_display;
-  gdk_root_parent.drawable.window_type = GDK_WINDOW_ROOT;
-  gdk_root_parent.drawable.drawable.user_data = NULL;
-  gdk_root_parent.drawable.width = width;
-  gdk_root_parent.drawable.height = height;
-  gdk_root_parent.children = NULL;
-  gdk_root_parent.drawable.colormap = NULL;
-  gdk_root_parent.drawable.ref_count = 1;
-  
-  gdk_xid_table_insert (&gdk_root_window, &gdk_root_parent);
+  gdk_xid_table_insert (&gdk_root_window, gdk_parent_root);
 }
 
 static GdkAtom wm_client_leader_atom = GDK_NONE;
@@ -249,16 +155,18 @@ gdk_window_new (GdkWindow     *parent,
   GdkWindow *window;
   GdkWindowPrivate *private;
   GdkWindowPrivate *parent_private;
+  
   GdkVisual *visual;
-  Display *parent_display;
   Window xparent;
   Visual *xvisual;
+
   XSetWindowAttributes xattributes;
   long xattributes_mask;
   XSizeHints size_hints;
   XWMHints wm_hints;
   XClassHint *class_hint;
   int x, y, depth;
+  
   unsigned int class;
   char *title;
   int i;
@@ -266,26 +174,21 @@ gdk_window_new (GdkWindow     *parent,
   g_return_val_if_fail (attributes != NULL, NULL);
   
   if (!parent)
-    parent = (GdkWindow*) &gdk_root_parent;
+    parent = gdk_parent_root;
   
   parent_private = (GdkWindowPrivate*) parent;
   if (GDK_DRAWABLE_DESTROYED (parent))
     return NULL;
   
-  xparent = parent_private->drawable.xwindow;
-  parent_display = parent_private->drawable.xdisplay;
+  xparent = GDK_DRAWABLE_XID (parent);
   
-  private = g_new (GdkWindowPrivate, 1);
-  window = (GdkWindow*) private;
+  window = gdk_x11_window_alloc ();
+  private = (GdkWindowPrivate *)window;
+
+  GDK_DRAWABLE_XDATA (window)->xdisplay = GDK_DRAWABLE_XDISPLAY (parent);
   
   private->parent = parent;
-  
-  private->drawable.xdisplay = parent_display;
-  private->drawable.destroyed = FALSE;
-  private->mapped = FALSE;
-  private->guffaw_gravity = FALSE;
-  private->resize_count = 0;
-  private->drawable.ref_count = 1;
+
   xattributes_mask = 0;
   
   if (attributes_mask & GDK_WA_X)
@@ -303,12 +206,6 @@ gdk_window_new (GdkWindow     *parent,
   private->drawable.width = (attributes->width > 1) ? (attributes->width) : (1);
   private->drawable.height = (attributes->height > 1) ? (attributes->height) : (1);
   private->drawable.window_type = attributes->window_type;
-  private->extension_events = FALSE;
-  
-  private->filters = NULL;
-  private->children = NULL;
-  
-  window->user_data = NULL;
   
   if (attributes_mask & GDK_WA_VISUAL)
     visual = attributes->visual;
@@ -363,26 +260,26 @@ gdk_window_new (GdkWindow     *parent,
       switch (private->drawable.window_type)
        {
        case GDK_WINDOW_TOPLEVEL:
-         xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
+         xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap);
          xattributes_mask |= CWColormap;
          
          xparent = gdk_root_window;
          break;
          
        case GDK_WINDOW_CHILD:
-         xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
+         xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap);
          xattributes_mask |= CWColormap;
          break;
          
        case GDK_WINDOW_DIALOG:
-         xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
+         xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap);
          xattributes_mask |= CWColormap;
          
          xparent = gdk_root_window;
          break;
          
        case GDK_WINDOW_TEMP:
-         xattributes.colormap = ((GdkColormapPrivate*) private->drawable.colormap)->xcolormap;
+         xattributes.colormap = GDK_COLORMAP_XCOLORMAP (private->drawable.colormap);
          xattributes_mask |= CWColormap;
          
          xparent = gdk_root_window;
@@ -406,13 +303,14 @@ gdk_window_new (GdkWindow     *parent,
       class = InputOnly;
       private->drawable.colormap = NULL;
     }
-  
-  private->drawable.xwindow = XCreateWindow (private->drawable.xdisplay, xparent,
-                                   x, y, private->drawable.width, private->drawable.height,
-                                   0, depth, class, xvisual,
-                                   xattributes_mask, &xattributes);
-  gdk_window_ref (window);
-  gdk_xid_table_insert (&private->drawable.xwindow, window);
+
+  GDK_DRAWABLE_XDATA (private)->xid = XCreateWindow (GDK_DRAWABLE_XDISPLAY (parent),
+                                                    xparent,
+                                                    x, y, private->drawable.width, private->drawable.height,
+                                                    0, depth, class, xvisual,
+                                                    xattributes_mask, &xattributes);
+  gdk_drawable_ref (window);
+  gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window);
   
   if (private->drawable.colormap)
     gdk_colormap_ref (private->drawable.colormap);
@@ -427,10 +325,14 @@ gdk_window_new (GdkWindow     *parent,
   switch (private->drawable.window_type)
     {
     case GDK_WINDOW_DIALOG:
-      XSetTransientForHint (private->drawable.xdisplay, private->drawable.xwindow, xparent);
+      XSetTransientForHint (GDK_DRAWABLE_XDISPLAY (window),
+                           GDK_DRAWABLE_XID (window),
+                           xparent);
     case GDK_WINDOW_TOPLEVEL:
     case GDK_WINDOW_TEMP:
-      XSetWMProtocols (private->drawable.xdisplay, private->drawable.xwindow, gdk_wm_window_protocols, 2);
+      XSetWMProtocols (GDK_DRAWABLE_XDISPLAY (window),
+                      GDK_DRAWABLE_XID (window),
+                      gdk_wm_window_protocols, 2);
       break;
     case GDK_WINDOW_CHILD:
       if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
@@ -460,14 +362,19 @@ gdk_window_new (GdkWindow     *parent,
    * attention to PSize, and even if they do, is this the
    * correct value???
    */
-  XSetWMNormalHints (private->drawable.xdisplay, private->drawable.xwindow, &size_hints);
+  XSetWMNormalHints (GDK_DRAWABLE_XDISPLAY (window),
+                    GDK_DRAWABLE_XID (window),
+                    &size_hints);
   
-  XSetWMHints (private->drawable.xdisplay, private->drawable.xwindow, &wm_hints);
+  XSetWMHints (GDK_DRAWABLE_XDISPLAY (window),
+              GDK_DRAWABLE_XID (window),
+              &wm_hints);
   
   if (!wm_client_leader_atom)
     wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE);
   
-  XChangeProperty (private->drawable.xdisplay, private->drawable.xwindow,
+  XChangeProperty (GDK_DRAWABLE_XDISPLAY (window),
+                  GDK_DRAWABLE_XID (window),
                   wm_client_leader_atom,
                   XA_WINDOW, 32, PropModeReplace,
                   (guchar*) &gdk_leader_window, 1);
@@ -477,7 +384,8 @@ gdk_window_new (GdkWindow     *parent,
   else
     title = g_get_prgname ();
   
-  XmbSetWMProperties (private->drawable.xdisplay, private->drawable.xwindow,
+  XmbSetWMProperties (GDK_DRAWABLE_XDISPLAY (window),
+                     GDK_DRAWABLE_XID (window),
                       title, title,
                       NULL, 0,
                       NULL, NULL, NULL);
@@ -487,11 +395,12 @@ gdk_window_new (GdkWindow     *parent,
       class_hint = XAllocClassHint ();
       class_hint->res_name = attributes->wmclass_name;
       class_hint->res_class = attributes->wmclass_class;
-      XSetClassHint (private->drawable.xdisplay, private->drawable.xwindow, class_hint);
+      XSetClassHint (GDK_DRAWABLE_XDISPLAY (window),
+                    GDK_DRAWABLE_XID (window),
+                    class_hint);
       XFree (class_hint);
     }
   
-  
   return window;
 }
 
@@ -518,12 +427,13 @@ gdk_window_foreign_new (guint32 anid)
   result = XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren);
   if (gdk_error_trap_pop () || !result)
     return NULL;
-  
-  private = g_new (GdkWindowPrivate, 1);
-  window = (GdkWindow*) private;
-  
+
   if (children)
     XFree (children);
+  
+  window = gdk_x11_window_alloc ();
+  private = (GdkWindowPrivate *)window;
+
   private->parent = gdk_xid_table_lookup (parent);
   
   parent_private = (GdkWindowPrivate *)private->parent;
@@ -531,29 +441,19 @@ gdk_window_foreign_new (guint32 anid)
   if (parent_private)
     parent_private->children = g_list_prepend (parent_private->children, window);
   
-  private->drawable.xwindow = anid;
-  private->drawable.xdisplay = gdk_display;
+  GDK_DRAWABLE_XDATA (window)->xid = anid;
+  GDK_DRAWABLE_XDATA (window)->xdisplay = GDK_DRAWABLE_XDISPLAY (parent);
+
   private->x = attrs.x;
   private->y = attrs.y;
   private->drawable.width = attrs.width;
   private->drawable.height = attrs.height;
-  private->resize_count = 0;
-  private->drawable.ref_count = 1;
   private->drawable.window_type = GDK_WINDOW_FOREIGN;
   private->drawable.destroyed = FALSE;
   private->mapped = (attrs.map_state != IsUnmapped);
-  private->guffaw_gravity = FALSE;
-  private->extension_events = 0;
-  
-  private->drawable.colormap = NULL;
   
-  private->filters = NULL;
-  private->children = NULL;
-  
-  window->user_data = NULL;
-  
-  gdk_window_ref (window);
-  gdk_xid_table_insert (&private->drawable.xwindow, window);
+  gdk_drawable_ref (window);
+  gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window);
   
   return window;
 }
@@ -646,20 +546,22 @@ gdk_window_internal_destroy (GdkWindow *window,
                  gdk_window_reparent (window, NULL, 0, 0);
                  
                  xevent.type = ClientMessage;
-                 xevent.window = private->drawable.xwindow;
+                 xevent.window = GDK_DRAWABLE_XID (window);
                  xevent.message_type = gdk_wm_protocols;
                  xevent.format = 32;
                  xevent.data.l[0] = gdk_wm_delete_window;
                  xevent.data.l[1] = CurrentTime;
 
-                 XSendEvent (private->drawable.xdisplay, private->drawable.xwindow,
+                 XSendEvent (GDK_DRAWABLE_XDISPLAY (window),
+                             GDK_DRAWABLE_XID (window),
                              False, 0, (XEvent *)&xevent);
                  gdk_flush ();
                  gdk_error_trap_pop ();
                }
            }
          else if (xdestroy)
-           XDestroyWindow (private->drawable.xdisplay, private->drawable.xwindow);
+           XDestroyWindow (GDK_DRAWABLE_XDISPLAY (window),
+                           GDK_DRAWABLE_XID (window));
          
          if (private->drawable.colormap)
            gdk_colormap_unref (private->drawable.colormap);
@@ -686,7 +588,7 @@ void
 gdk_window_destroy (GdkWindow *window)
 {
   gdk_window_internal_destroy (window, TRUE, TRUE);
-  gdk_window_unref (window);
+  gdk_drawable_unref (window);
 }
 
 /* This function is called when the XWindow is really gone.  */
@@ -705,38 +607,7 @@ gdk_window_destroy_notify (GdkWindow *window)
     }
   
   gdk_xid_table_remove (GDK_DRAWABLE_XID (window));
-  gdk_window_unref (window);
-}
-
-GdkWindow*
-gdk_window_ref (GdkWindow *window)
-{
-  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
-  g_return_val_if_fail (window != NULL, NULL);
-  
-  private->drawable.ref_count += 1;
-  return window;
-}
-
-void
-gdk_window_unref (GdkWindow *window)
-{
-  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
-  g_return_if_fail (window != NULL);
-  
-  private->drawable.ref_count -= 1;
-  if (private->drawable.ref_count == 0)
-    {
-      if (!private->drawable.destroyed)
-       {
-         if (private->drawable.window_type == GDK_WINDOW_FOREIGN)
-           gdk_xid_table_remove (private->drawable.xwindow);
-         else
-           g_warning ("losing last reference to undestroyed window\n");
-       }
-      g_dataset_destroy (window);
-      g_free (window);
-    }
+  gdk_drawable_unref (window);
 }
 
 void
@@ -750,8 +621,10 @@ gdk_window_show (GdkWindow *window)
   if (!private->drawable.destroyed)
     {
       private->mapped = TRUE;
-      XRaiseWindow (private->drawable.xdisplay, private->drawable.xwindow);
-      XMapWindow (private->drawable.xdisplay, private->drawable.xwindow);
+      XRaiseWindow (GDK_DRAWABLE_XDISPLAY (window),
+                   GDK_DRAWABLE_XID (window));
+      XMapWindow (GDK_DRAWABLE_XDISPLAY (window),
+                 GDK_DRAWABLE_XID (window));
     }
 }
 
@@ -766,7 +639,8 @@ gdk_window_hide (GdkWindow *window)
   if (!private->drawable.destroyed)
     {
       private->mapped = FALSE;
-      XUnmapWindow (private->drawable.xdisplay, private->drawable.xwindow);
+      XUnmapWindow (GDK_DRAWABLE_XDISPLAY (window),
+                   GDK_DRAWABLE_XID (window));
     }
 }
 
@@ -779,7 +653,8 @@ gdk_window_withdraw (GdkWindow *window)
   
   private = (GdkWindowPrivate*) window;
   if (!private->drawable.destroyed)
-    XWithdrawWindow (private->drawable.xdisplay, private->drawable.xwindow, 0);
+    XWithdrawWindow (GDK_DRAWABLE_XDISPLAY (window),
+                    GDK_DRAWABLE_XID (window), 0);
 }
 
 void
@@ -794,7 +669,9 @@ gdk_window_move (GdkWindow *window,
   private = (GdkWindowPrivate*) window;
   if (!private->drawable.destroyed)
     {
-      XMoveWindow (private->drawable.xdisplay, private->drawable.xwindow, x, y);
+      XMoveWindow (GDK_DRAWABLE_XDISPLAY (window),
+                  GDK_DRAWABLE_XID (window),
+                  x, y);
       
       if (private->drawable.window_type == GDK_WINDOW_CHILD)
        {
@@ -904,7 +781,7 @@ gdk_window_reparent (GdkWindow *window,
   g_return_if_fail (GDK_IS_WINDOW (new_parent));
   
   if (!new_parent)
-    new_parent = (GdkWindow*) &gdk_root_parent;
+    new_parent = gdk_parent_root;
   
   window_private = (GdkWindowPrivate*) window;
   old_parent_private = (GdkWindowPrivate*)window_private->parent;
@@ -989,15 +866,6 @@ gdk_window_lower (GdkWindow *window)
     XLowerWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window));
 }
 
-void
-gdk_window_set_user_data (GdkWindow *window,
-                         gpointer   user_data)
-{
-  g_return_if_fail (window != NULL);
-  
-  window->user_data = user_data;
-}
-
 void
 gdk_window_set_hints (GdkWindow *window,
                      gint       x,
@@ -1243,15 +1111,6 @@ gdk_window_set_cursor (GdkWindow *window,
                   xcursor);
 }
 
-void
-gdk_window_get_user_data (GdkWindow *window,
-                         gpointer  *data)
-{
-  g_return_if_fail (window != NULL);
-  
-  *data = window->user_data;
-}
-
 void
 gdk_window_get_geometry (GdkWindow *window,
                         gint      *x,
@@ -1271,7 +1130,7 @@ gdk_window_get_geometry (GdkWindow *window,
   g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
   
   if (!window)
-    window = (GdkWindow *) &gdk_root_parent;
+    window = gdk_parent_root;
   
   if (!GDK_DRAWABLE_DESTROYED (window))
     {
@@ -1292,24 +1151,6 @@ gdk_window_get_geometry (GdkWindow *window,
     }
 }
 
-void
-gdk_window_get_position (GdkWindow *window,
-                        gint      *x,
-                        gint      *y)
-{
-  GdkWindowPrivate *window_private;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  
-  window_private = (GdkWindowPrivate*) window;
-  
-  if (x)
-    *x = window_private->x;
-  if (y)
-    *y = window_private->y;
-}
-
 gint
 gdk_window_get_origin (GdkWindow *window,
                       gint      *x,
@@ -1481,7 +1322,7 @@ gdk_window_get_pointer (GdkWindow       *window,
   g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
   
   if (!window)
-    window = (GdkWindow*) &gdk_root_parent;
+    window = gdk_parent_root;
   
   return_val = NULL;
   if (!GDK_DRAWABLE_DESTROYED (window) &&
@@ -1507,31 +1348,29 @@ GdkWindow*
 gdk_window_at_pointer (gint *win_x,
                       gint *win_y)
 {
-  GdkWindowPrivate *private;
   GdkWindow *window;
   Window root;
   Window xwindow;
   Window xwindow_last = 0;
+  Display *xdisplay;
   int rootx = -1, rooty = -1;
   int winx, winy;
   unsigned int xmask;
   
-  private = &gdk_root_parent;
+  xwindow = GDK_ROOT_WINDOW ();
+  xdisplay = GDK_DISPLAY ();
   
-  xwindow = private->drawable.xwindow;
-  
-  XGrabServer (private->drawable.xdisplay);
+  XGrabServer (xdisplay);
   while (xwindow)
     {
       xwindow_last = xwindow;
-      XQueryPointer (private->drawable.xdisplay,
-                    xwindow,
+      XQueryPointer (xdisplay, xwindow,
                     &root, &xwindow,
                     &rootx, &rooty,
                     &winx, &winy,
                     &xmask);
     }
-  XUngrabServer (private->drawable.xdisplay);
+  XUngrabServer (xdisplay);
   
   window = gdk_window_lookup (xwindow_last);
   
@@ -1543,30 +1382,6 @@ gdk_window_at_pointer (gint *win_x,
   return window;
 }
 
-GdkWindow*
-gdk_window_get_parent (GdkWindow *window)
-{
-  g_return_val_if_fail (window != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-  
-  return ((GdkWindowPrivate*) window)->parent;
-}
-
-GdkWindow*
-gdk_window_get_toplevel (GdkWindow *window)
-{
-  GdkWindowPrivate *private;
-  
-  g_return_val_if_fail (window != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
-  private = (GdkWindowPrivate *)window;
-  while (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD)
-    private = (GdkWindowPrivate *)private->parent;
-  
-  return (GdkWindow *)window;
-}
-
 GList*
 gdk_window_get_children (GdkWindow *window)
 {
@@ -1765,84 +1580,6 @@ gdk_window_shape_combine_mask (GdkWindow *window,
 #endif /* HAVE_SHAPE_EXT */
 }
 
-void          
-gdk_window_add_filter (GdkWindow     *window,
-                      GdkFilterFunc  function,
-                      gpointer       data)
-{
-  GdkWindowPrivate *private;
-  GList *tmp_list;
-  GdkEventFilter *filter;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-
-  private = (GdkWindowPrivate*) window;
-  if (private && GDK_DRAWABLE_DESTROYED (window))
-    return;
-  
-  if (private)
-    tmp_list = private->filters;
-  else
-    tmp_list = gdk_default_filters;
-  
-  while (tmp_list)
-    {
-      filter = (GdkEventFilter *)tmp_list->data;
-      if ((filter->function == function) && (filter->data == data))
-       return;
-      tmp_list = tmp_list->next;
-    }
-  
-  filter = g_new (GdkEventFilter, 1);
-  filter->function = function;
-  filter->data = data;
-  
-  if (private)
-    private->filters = g_list_append (private->filters, filter);
-  else
-    gdk_default_filters = g_list_append (gdk_default_filters, filter);
-}
-
-void
-gdk_window_remove_filter (GdkWindow     *window,
-                         GdkFilterFunc  function,
-                         gpointer       data)
-{
-  GdkWindowPrivate *private;
-  GList *tmp_list, *node;
-  GdkEventFilter *filter;
-  
-  g_return_if_fail (window != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (window));
-
-  private = (GdkWindowPrivate*) window;
-  
-  if (private)
-    tmp_list = private->filters;
-  else
-    tmp_list = gdk_default_filters;
-  
-  while (tmp_list)
-    {
-      filter = (GdkEventFilter *)tmp_list->data;
-      node = tmp_list;
-      tmp_list = tmp_list->next;
-      
-      if ((filter->function == function) && (filter->data == data))
-       {
-         if (private)
-           private->filters = g_list_remove_link (private->filters, node);
-         else
-           gdk_default_filters = g_list_remove_link (gdk_default_filters, node);
-         g_list_free_1 (node);
-         g_free (filter);
-         
-         return;
-       }
-    }
-}
-
 void
 gdk_window_set_override_redirect (GdkWindow *window,
                                  gboolean override_redirect)
@@ -2038,29 +1775,12 @@ gdk_window_set_functions (GdkWindow    *window,
   gdk_window_set_mwm_hints (window, &hints);
 }
 
-GList *
-gdk_window_get_toplevels (void)
-{
-  GList *new_list = NULL;
-  GList *tmp_list;
-  
-  tmp_list = gdk_root_parent.children;
-  while (tmp_list)
-    {
-      new_list = g_list_prepend (new_list, tmp_list->data);
-      tmp_list = tmp_list->next;
-    }
-  
-  return new_list;
-}
-
 /* 
  * propagate the shapes from all child windows of a GDK window to the parent 
  * window. Shamelessly ripped from Enlightenment's code
  * 
  * - Raster
  */
-
 struct _gdk_span
 {
   gint                start;
@@ -2395,59 +2115,6 @@ gdk_window_merge_child_shapes (GdkWindow *window)
 #endif   
 }
 
-/*************************************************************
- * gdk_window_is_visible:
- *     Check if the given window is mapped.
- *   arguments:
- *     window: 
- *   results:
- *     is the window mapped
- *************************************************************/
-
-gboolean 
-gdk_window_is_visible (GdkWindow *window)
-{
-  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
-  
-  g_return_val_if_fail (window != NULL, FALSE);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
-  
-  return private->mapped;
-}
-
-/*************************************************************
- * gdk_window_is_viewable:
- *     Check if the window and all ancestors of the window
- *     are mapped. (This is not necessarily "viewable" in
- *     the X sense, since we only check as far as we have
- *     GDK window parents, not to the root window)
- *   arguments:
- *     window:
- *   results:
- *     is the window viewable
- *************************************************************/
-
-gboolean 
-gdk_window_is_viewable (GdkWindow *window)
-{
-  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
-  
-  g_return_val_if_fail (window != NULL, FALSE);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
-  
-  while (private && 
-        (private != &gdk_root_parent) &&
-        (private->drawable.window_type != GDK_WINDOW_FOREIGN))
-    {
-      if (!private->mapped)
-       return FALSE;
-      
-      private = (GdkWindowPrivate *)private->parent;
-    }
-  
-  return TRUE;
-}
-
 /* Support for windows that can be guffaw-scrolled
  * (See http://www.gtk.org/~otaylor/whitepapers/guffaw-scrolling.txt)
  */
@@ -2581,3 +2248,135 @@ gdk_window_set_static_gravities (GdkWindow *window,
   
   return TRUE;
 }
+
+/* internal function created for and used by gdk_window_xid_at_coords */
+Window
+gdk_window_xid_at (Window   base,
+                  gint     bx,
+                  gint     by,
+                  gint     x,
+                  gint     y, 
+                  GList   *excludes,
+                  gboolean excl_child)
+{
+  Display *xdisplay;
+  Window *list = NULL;
+  Window child = 0, parent_win = 0, root_win = 0;
+  int i;
+  unsigned int ww, wh, wb, wd, num;
+  int wx, wy;
+  
+  xdisplay = GDK_DISPLAY ();
+  if (!XGetGeometry (xdisplay, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd))
+    return 0;
+  wx += bx;
+  wy += by;
+  
+  if (!((x >= wx) &&
+       (y >= wy) &&
+       (x < (int) (wx + ww)) &&
+       (y < (int) (wy + wh))))
+    return 0;
+  
+  if (!XQueryTree (xdisplay, base, &root_win, &parent_win, &list, &num))
+    return base;
+  
+  if (list)
+    {
+      for (i = num - 1; ; i--)
+       {
+         if ((!excl_child) || (!g_list_find (excludes, (gpointer *) list[i])))
+           {
+             if ((child = gdk_window_xid_at (list[i], wx, wy, x, y, excludes, excl_child)) != 0)
+               {
+                 XFree (list);
+                 return child;
+               }
+           }
+         if (!i)
+           break;
+       }
+      XFree (list);
+    }
+  return base;
+}
+
+/* 
+ * The following fucntion by The Rasterman <raster@redhat.com>
+ * This function returns the X Window ID in which the x y location is in 
+ * (x and y being relative to the root window), excluding any windows listed
+ * in the GList excludes (this is a list of X Window ID's - gpointer being
+ * the Window ID).
+ * 
+ * This is primarily designed for internal gdk use - for DND for example
+ * when using a shaped icon window as the drag object - you exclude the
+ * X Window ID of the "icon" (perhaps more if excludes may be needed) and
+ * You can get back an X Window ID as to what X Window ID is infact under
+ * those X,Y co-ordinates.
+ */
+Window
+gdk_window_xid_at_coords (gint     x,
+                         gint     y,
+                         GList   *excludes,
+                         gboolean excl_child)
+{
+  GdkWindow *window;
+  GdkDrawablePrivate *private;
+  Display *xdisplay;
+  Window *list = NULL;
+  Window root, child = 0, parent_win = 0, root_win = 0;
+  unsigned int num;
+  int i;
+
+  window = gdk_parent_root;
+  private = (GdkDrawablePrivate*) window;
+  xdisplay = GDK_DRAWABLE_XDISPLAY (private);
+  root = GDK_DRAWABLE_XID (private);
+  num = g_list_length (excludes);
+  
+  XGrabServer (xdisplay);
+  if (!XQueryTree (xdisplay, root, &root_win, &parent_win, &list, &num))
+    {
+      XUngrabServer (xdisplay);
+      return root;
+    }
+  if (list)
+    {
+      i = num - 1;
+      do
+       {
+         XWindowAttributes xwa;
+         
+         XGetWindowAttributes (xdisplay, list [i], &xwa);
+         
+         if (xwa.map_state != IsViewable)
+           continue;
+         
+         if (excl_child && g_list_find (excludes, (gpointer *) list[i]))
+           continue;
+         
+         if ((child = gdk_window_xid_at (list[i], 0, 0, x, y, excludes, excl_child)) == 0)
+           continue;
+         
+         if (excludes)
+           {
+             if (!g_list_find (excludes, (gpointer *) child))
+               {
+                 XFree (list);
+                 XUngrabServer (xdisplay);
+                 return child;
+               }
+           }
+         else
+           {
+             XFree (list);
+             XUngrabServer (xdisplay);
+             return child;
+           }
+       } while (--i > 0);
+      XFree (list);
+    }
+  XUngrabServer (xdisplay);
+  return root;
+}
+
index 4f142bd1ef30cf03ffba4ef276f72aa2d0898a49..dcbd26b803d94f360ff429aa7ca589f533ebf673 100644 (file)
 #ifndef __GDK_X_H__
 #define __GDK_X_H__
 
-#include <gdk/gdkprivate.h>
-
+#include <gdk/x11/gdkprivate-x11.h>
 
 #define GDK_ROOT_WINDOW()             gdk_root_window
-#define GDK_ROOT_PARENT()             ((GdkWindow *)&gdk_root_parent)
+#define GDK_ROOT_PARENT()             ((GdkWindow *)&gdk_parent_root)
 #define GDK_DISPLAY()                 gdk_display
-#define GDK_DRAWABLE_XDISPLAY(win)    (((GdkDrawablePrivate*) win)->xdisplay)
-#define GDK_DRAWABLE_XID(win)         (((GdkDrawablePrivate*) win)->xwindow)
-#define GDK_WINDOW_XDISPLAY           GDK_DRAWABLE_XDISPLAY
-#define GDK_WINDOW_XWINDOW            GDK_DRAWABLE_XID
+#define GDK_DRAWABLE_XDISPLAY(win)    (GDK_DRAWABLE_XDATA(win)->xdisplay)
+#define GDK_DRAWABLE_XID(win)         (GDK_DRAWABLE_XDATA(win)->xid)
 #define GDK_IMAGE_XDISPLAY(image)     (((GdkImagePrivate*) image)->xdisplay)
 #define GDK_IMAGE_XIMAGE(image)       (((GdkImagePrivate*) image)->ximage)
-#define GDK_GC_XDISPLAY(gc)           (((GdkGCPrivate*) gc)->xdisplay)
-#define GDK_GC_XGC(gc)                (((GdkGCPrivate*) gc)->xgc)
-#define GDK_COLORMAP_XDISPLAY(cmap)   (((GdkColormapPrivate*) cmap)->xdisplay)
-#define GDK_COLORMAP_XCOLORMAP(cmap)  (((GdkColormapPrivate*) cmap)->xcolormap)
+#define GDK_GC_XDISPLAY(gc)           (GDK_GC_XDATA(gc)->xdisplay)
+#define GDK_GC_XGC(gc)                (GDK_GC_XDATA(gc)->xgc)
+#define GDK_COLORMAP_XDISPLAY(cmap)   (((GdkColormapPrivateX *)cmap)->xdisplay)
+#define GDK_COLORMAP_XCOLORMAP(cmap)  (((GdkColormapPrivateX *)cmap)->xcolormap)
 #define GDK_VISUAL_XVISUAL(vis)       (((GdkVisualPrivate*) vis)->xvisual)
 #define GDK_FONT_XDISPLAY(font)       (((GdkFontPrivate*) font)->xdisplay)
-#define GDK_FONT_XFONT(font)          (((GdkFontPrivate*) font)->xfont)
+#define GDK_FONT_XFONT(font)          (((GdkFontPrivateX *)font)->xfont)
 
+#define GDK_WINDOW_XWINDOW            GDK_DRAWABLE_XID
+#define GDK_WINDOW_XDISPLAY           GDK_DRAWABLE_XDISPLAY
 
 GdkVisual*   gdkx_visual_get   (VisualID xvisualid);
 /* XXX: Do not use this function until it is fixed. An X Colormap
@@ -58,7 +57,7 @@ Window        gdk_get_client_window      (Display  *dpy,
                                           Window    win);
 
 /* Functions to create pixmaps and windows from their X equivalents */
-GdkPixmap    *gdk_pixmap_foreign_new (guint32     anid);
-GdkWindow    *gdk_window_foreign_new (guint32       anid);
+GdkPixmap    *gdk_pixmap_foreign_new (guint32 anid);
+GdkWindow    *gdk_window_foreign_new (guint32 anid);
 
 #endif /* __GDK_X_H__ */
index 706738673284a3fb7d4353b57c920dc10917eff8..2c5a9c7410078136b7a2b4be7a5fca91f309f5b7 100644 (file)
@@ -24,7 +24,7 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include "gdkprivate.h"
+#include "gdkprivate-x11.h"
 #include <stdio.h>
 
 static guint gdk_xid_hash    (XID *xid);
index b55a944e46f3213f3bd357856a8a82c53b75db61..01ccba147d9c92c84e20789aa53104f68915edb5 100644 (file)
@@ -418,6 +418,7 @@ INCLUDES = \
        -DGTK_LOCALEDIR=\"$(gtklocaledir)\"             \
        -I$(top_srcdir) -I../gdk                        \
        -I$(top_srcdir)/gdk                             \
+       -I$(top_srcdir)/gdk/x11                         \
        @GTK_DEBUG_FLAGS@                               \
        @GTK_XIM_FLAGS@                                 \
        @GTK_LOCALE_FLAGS@                              \
index 0d804bae214ef8c6b7832a2ac41ecbd9b8c99f9d..51ac815d7a870d9f0dd600a04a3af56e86dcd2c7 100644 (file)
@@ -411,7 +411,6 @@ struct _GtkWidgetShapeInfo
   GdkBitmap *shape_mask;
 };
 
-
 GtkType           gtk_widget_get_type            (void);
 GtkWidget* gtk_widget_new                (GtkType              type,
                                           const gchar         *first_arg_name,
index dd73ca8d0e4bae5c492938d280e4a889fac5c2e9..17ff562b7899d5efba6d4d31cbacf96dd526d054 100644 (file)
@@ -14,7 +14,8 @@ main (int argc, char *argv[])
   GtkWidget *window;
   GtkWidget *button;
 
-  gdk_progclass = g_strdup ("XTerm");
+  /* FIXME: This is not allowable - what is this supposed to be? */
+  /*  gdk_progclass = g_strdup ("XTerm"); */
   gtk_init (&argc, &argv);
 
   window = gtk_widget_new (gtk_window_get_type (),
index dd73ca8d0e4bae5c492938d280e4a889fac5c2e9..17ff562b7899d5efba6d4d31cbacf96dd526d054 100644 (file)
@@ -14,7 +14,8 @@ main (int argc, char *argv[])
   GtkWidget *window;
   GtkWidget *button;
 
-  gdk_progclass = g_strdup ("XTerm");
+  /* FIXME: This is not allowable - what is this supposed to be? */
+  /*  gdk_progclass = g_strdup ("XTerm"); */
   gtk_init (&argc, &argv);
 
   window = gtk_widget_new (gtk_window_get_type (),